简体   繁体   English

在jQuery Mobile网站中是否可以将jQuery和jQuery Mobile库保持在底部?

[英]In jQuery Mobile Website Is it ok to keep jQuery and jQuery Mobile library at bottom?

In jquery mobile website there 3 things to add. 在jquery移动网站中,要添加3件事。

1 css file 1个CSS文件

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0b3/jquery.mobile-1.0b3.min.css" />

JQuery Library jQuery库

<script src="http://code.jquery.com/jquery-1.6.2.min.js"></script>

jQuery Mobile Library jQuery Mobile库

<script src="http://code.jquery.com/mobile/1.0b3/jquery.mobile-1.0b3.min.js"></script>

My question is , is it ok to use js libraries at bottom just before . 我的问题是,可以在底部使用js库吗? Becuase it will improve the loading speed. 因为它将提高加载速度。 jQuery adds css throught javascript classes jQuery通过JavaScript类添加CSS

As long as the main body doesn't require the use of the libraries, yes it all right to put your js libraries at the bottom. 只要主体不需要使用库,是的,可以将您的js库放在底部。 In fact it's a common practice to that, so that the main body is ready to play with instead of using $(document).ready( function () { /* code */ ) ); 实际上,这是一种常见的做法,因此主体可以随时使用,而不是使用$(document).ready( function () { /* code */ ) ); .

Simplest approach is probably just to test it. 最简单的方法可能只是对其进行测试。 However, in an app of mine that uses jQM version 1.0a4, placing the jQM Javascript and CSS files right at the end of the mark-up was fine. 但是,在我的使用jQM 1.0a4版的应用程序中,将jQM Javascript和CSS文件放在标记的末尾很好。 The docs advise that you place your custom $.mobile calls before referencing the jQM Javascript source anyway: 该文档建议您无论如何都要引用jQM Javascript源之前进行自定义的$.mobile调用:

Because the mobileinit event is triggered immediately upon execution, you'll need to bind your event handler before jQuery Mobile is loaded. 由于mobileinit事件是在执行后立即触发的,因此您需要在加载jQuery Mobile之前绑定事件处理程序。 Thus, we recommend linking to your JavaScript files in the following order: 因此,我们建议按以下顺序链接到您的JavaScript文件:

<script src="jquery.js"></script>
<script src="custom-scripting.js"></script>
<script src="jquery-mobile.js"></script>

http://jquerymobile.com/demos/1.0b3/docs/api/globalconfig.html http://jquerymobile.com/demos/1.0b3/docs/api/globalconfig.html

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

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