I use google code to defer loading javascript (google pages)
But I have some inline javascripts such as:
You cannot use jQuery before it is loaded. If you move the at the bottom of your page you must also move all the lines that use $(...) below it.
There is a tricky solution that goes something along these lines:
1) Defining few variables at the top of your page:
var _jqq = [];
var $ = function(fn) {
_jqq.push(fn);
};
2) In the middle of the page you can write:
$(function() {
alert("document ready callback #1");
});
$(function() {
alert("document ready callback #2");
});
3) At the bottom of your page, include jQuery:
4) And finally:
$(function() {
$.each(_jqq, function(i, fn) {
fn();
});
});
Demo