加载外部JS文件的进度 [英] Progress of loading external JS file

查看:132
本文介绍了加载外部JS文件的进度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定这会被称为知道要搜索什么,如果这是重复的话请链接我:)

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆