加载外部JS文件的进度 [英] Progress of loading external JS file
问题描述
我不确定这会被称为知道要搜索什么,如果这是重复的话请链接我:)
I'm not sure what this would be called to know what to search for, if this is a duplicate please link me :)
是否可以在JavaScript中使用在浏览器中,加载外部文件(这个位很容易),但考虑到外部文件可能相当大(比如说50MB),显示加载该文件的进度指示器?
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?
即我知道文件的服务器端大小,不知道gzip大小,我想说X%的文件加载。
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.
问题:尝试按需加载50MB JavaScript库,但显示加载进度。
Problem: Trying to load up a 50MB JavaScript library on demand but show the progress of the loading.
推荐答案
使用XMLHttpRequest加载脚本并监控其进度 。完成后, eval()
it。
Use XMLHttpRequest to load the script and monitor its progress. When it's done, eval()
it.
这篇关于加载外部JS文件的进度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!