开发者

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.

1 css file

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

JQuery Library

<script src="http://code.jquery.com/jquery-1.6.2.min.js"></scr开发者_开发问答ipt>

jQuery Mobile Library

<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 . Becuase it will improve the loading speed. jQuery adds css throught javascript classes


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. 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 */ ) );.


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. The docs advise that you place your custom $.mobile calls before referencing the jQM Javascript source anyway:

Because the mobileinit event is triggered immediately upon execution, you'll need to bind your event handler before jQuery Mobile is loaded. Thus, we recommend linking to your JavaScript files in the following order:

<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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜