脚本和图像加载器
我有大量的 HTML 页面,其中包含几兆字节的图像和脚本。我想使用 JavaScript(如 Flash)显示加载程序 - 带有进度条和百分比。
是否有任何带有 input: URL 数组(js 脚本和图像)的库,可以在加载某些内容时进行回调。我知道资源的大小,所以我能够制作进度条。
如果加载器库非常轻或者使用 jQuery 会更好。 另外,如果它可以加载 CSS,那就太好了(我使用 LESS,但应该是相同的)。
I have heavy HTML-page with several megabytes of images and scripts. I'd like to show loader using javascript like Flash - with progressbar and percents.
Is there any library with input: array of URLs (js scripts and images) that makes callback when something is loaded. I know sizes of resources so I'll be able to make progressbar.
It would be better if loader library is very light or uses jQuery.
Also if it can load CSS it's great (I use LESS but should be the same).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道有什么开箱即用的插件可以实现您所追求的目标。但是,您应该能够在 .load() 和 .load() 和 .progressbar()。
一般想法是显示您默认加载 gfx,而其他所有内容都隐藏。一切加载完毕后,将显示您的主 UI。
这里的关键是$(window).load()。
I don't know any out of the box plugins that will achieve what you are after. However you should be able to write your own with help from .load() and .progressbar().
General idea would be to show you loading gfx by default with everything else hidden. Once everything has loaded then show your main UI.
Key here is $(window).load().
jQuery 帮助:
url.substr(0, 7) != 'http://'
):$.get(url, function(data){eval(data);回调(url)}
$.getScript(url, function(){callback(url)})
var el = new Image();加载= function(){callback(url)}; el.src = url;
我有包含 url 和大小的数组,因此我知道已经下载了多少内容和总大小。
jQuery helps:
url.substr(0, 7) != 'http://'
):$.get(url, function(data){eval(data); callback(url)}
$.getScript(url, function(){callback(url)})
var el = new Image(); el.onload = function(){callback(url)}; el.src = url;
And I have array with urls and sizes so I know how much was already downloaded and total size.