Bootstrap javascript at very end and jQuery $(document).ready - Stack Overflow

Much of jQuery depends on $(document).ready ... why does bootstrap 2.0 include the javascript library c

Much of jQuery depends on $(document).ready ... why does bootstrap 2.0 include the javascript library calls at the very end?

Is there a way to get $(document).ready to work keeping the js lib calls at the very end?


Update: A mon example (and the source of my frustration!) is $("#id").click(), which does not seem to work if you do not place it inside the .ready function...

Much of jQuery depends on $(document).ready ... why does bootstrap 2.0 include the javascript library calls at the very end?

Is there a way to get $(document).ready to work keeping the js lib calls at the very end?


Update: A mon example (and the source of my frustration!) is $("#id").click(), which does not seem to work if you do not place it inside the .ready function...

Share Improve this question edited Mar 16, 2012 at 11:29 ina asked Mar 16, 2012 at 11:05 inaina 19.5k41 gold badges127 silver badges209 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

jQuery only "depends" on $(document).ready() to support scripts that are evaluated while the document is still being loaded (e.g. scripts residing in the document's <head> or halfway through its <body>).

Placing scripts at the end ensures the rest of the document is loaded by the time the scripts are evaluated, so $(document).ready() is not necessary in that case.

I expect it loads it at the end of the file to improve the performance - see Yahoo best practices.

Can you put your own JS script tag after the jQuery load? If you put it after the jQuery load it should work and it should also allow your page to display whilst your code is loaded.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745213385a4616975.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信