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...
2 Answers
Reset to default 4jQuery 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条)