jQuery inclusion
Posted: Sat Jan 01, 2011 1:43 pm
While I applaud the decision to include jQuery to the core (svn, trunk), I have some suggestions on how to do that. I'm not sure if these are included in Garvins commit since I haven't checked it out live yet due to some New Year's fatigue.
A. If at all possible, jQuery as well as all other JS should not be included in the <head> but at the bottom of the page, right before the </body> tag, for performance reasons. I realize this might be difficult since a lot of plugins right now include JS files or <script> tags anywhere they please, but I think if we're gonna go this route, we might just as well do it the right way, even if it requires some major changes.
B. I'd also recommend using the local copy as a fallback to a CDN hosted version. Here's an example how to do that taken from Paul Irish's HTML5 boilerplate:
(Of course, the path to the local copy needs to be adapted to S9y.)
Unfortunately, Google does not offer a way to "always use the latest jQuery", but since we'd have to maintain a local copy of the file anyway ...
YL
A. If at all possible, jQuery as well as all other JS should not be included in the <head> but at the bottom of the page, right before the </body> tag, for performance reasons. I realize this might be difficult since a lot of plugins right now include JS files or <script> tags anywhere they please, but I think if we're gonna go this route, we might just as well do it the right way, even if it requires some major changes.
B. I'd also recommend using the local copy as a fallback to a CDN hosted version. Here's an example how to do that taken from Paul Irish's HTML5 boilerplate:
Code: Select all
<!-- Grab Google CDN's jQuery. fall back to local if necessary -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.js"></script>
<script>!window.jQuery && document.write(unescape('%3Cscript src="js/libs/jquery-1.4.4.js"%3E%3C/script%3E'))</script>
Unfortunately, Google does not offer a way to "always use the latest jQuery", but since we'd have to maintain a local copy of the file anyway ...
YL