Yahoo suggests to load scripts at the bottom of an HTML pages for performance reasons. I use HTML5 Boilerplate, which honour the rule.
The problem with this approach is that jQuery is loaded at the bottom, too. If for some reason I need to write inline javascript containing jQuery code I can't, because $
is not yet available in the namespace.
This happens for example with galleria.js (jQuery image gallery engine), which requires this markup:
<div id="gallery">
<img src="/media/img1.png" />
<img src="/media/img2.png" />
</div>
<script>
$('#gallery').css('height', '200px'); // this is required for galleria to work
Galleria.run('#gallery');
</script>
The code to set the height of #gallery
doesn't work because jQuery gets loaded later. Firebug console gives:
ReferenceError: $ is not defined
Any hint to posticipate the execution of <script>
block until the $
symbol can be found in the namespace?