最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin0浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论