English 中文(简体)
Javascript: 我如何用“技能”来装载物体?
原标题:Javascript: How do I "kill" the loading of an object?

其他网站的参考物体(日志、文字、果等)。 有时,另一地点倒塌,我不得不等待大约30秒钟的我的浏览器,等待这个物体的“能力”。 比如,在5秒之后,我怎么能“ski”物体?

这里有一些样本代码:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script>window.jQuery || document.write( <script src="js/libs/jquery-1.6.2.min.js"></script> )</script>
最佳回答

http://yepnopejs.com/“rel=“nofollow”>yepnope。 这里,从家庭一页起便可直截:

yepnope.js has the capability to do resource fallbacks and still download dependent scripts in parallel with the first. More clearly:

yepnope([{
  load:  http:/­/ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js ,
  complete: function () {
    if (!window.jQuery) {
      yepnope( local/jquery.min.js );
    }
  }
}, {
  load:  jquery.plugin.js ,
  complete: function () {
    jQuery(function () {
      jQuery( div ).plugin();
    });
  }
}]);

我建议,在决定是否自行滚动之前,先调查“是”和其他现有文字装载器。 这些装载器非常小(大鼠索赔为1.6千B),因此,通过撰写你自己的解决办法,没有什么好处。

问题回答

HTML5 has the async attribute for script elements that offsets this difficulty by allowing scripts to load asynchronously. Some browsers additionally implement a non-standard defer attribute that is similar, but not exactly the same. As for resources besides scripts, such as images, you can actually use JavaScript to cause them to load asynchronously (for example, by creating the image element on the fly). The downside to this approach is that if your asynchronous JavaScript subsequently causes asynchronous images to load, you run a very high risk of a FOUC.





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签