Bind handlers to DOM ready before jQuery is loaded.
http://benalman.com/
HTML
<!-- Idea from https://gist.github.com/663043 -->
<script>
(function(window){
var tmp = window.jQuery = window.$ = function( fn ) {
if ( Object.prototype.toString.call( fn ) === '[object Function]' ) {
tmp.queue.push( fn );
}
};
tmp.queue = [];
})(window);
$(function(){
console.log(1);
});
$(function(){
console.log(2);
});
</script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
<script>
$(function(){
console.log(3);
});
// Copy all queued DOM ready callbacks into jQuery's internal
(function(window,$){
$.map( window.$.queue, $ );
window.$ = $;
})(window,jQuery.noConflict());
$(function(){
console.log(4);
});
</script>