简体   繁体   English

加载外部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 :) 我不知道这会被称为什么搜索,如果这是重复请链接我:)

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? 是否可以在浏览器的JavaScript中加载外部文件(这一点很容易),但考虑到外部文件可能相当大(比如50MB)显示加载该文件的进度指示器?

ie I, knowing the serverside size of the file, not knowing the gzip size, I want to say X% of file loaded. 即我,知道文件的服务器端大小,不知道gzip大小,我想说X%的文件加载。

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. 问题:尝试按需加载50MB JavaScript库,但显示加载进度。

Use XMLHttpRequest to load the script and monitor its progress . 使用XMLHttpRequest加载脚本并监视其进度 When it's done, eval() it. 当它完成后, eval()就可以了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM