Progress of loading external JS file

萝らか妹 提交于 2019-12-21 12:26:01

问题


I'm not sure what this would be called to know what to search for, if this is a duplicate please link me :)

Is it possible in JavaScript in a browser, to load an external file (this bit is easy), but given that the external file could be rather large (say 50MB) show a progress indicator of the loading of that file?

i.e I, knowing the serverside size of the file, not knowing the gzip size, I want to say X% of file loaded.

I've not tried anything, I can't find anything to work from let alone find something that suggests its possible.

Problem: Trying to load up a 50MB JavaScript library on demand but show the progress of the loading.


回答1:


Use XMLHttpRequest to load the script and monitor its progress. When it's done, eval() it.



来源:https://stackoverflow.com/questions/20014933/progress-of-loading-external-js-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!