Created
August 26, 2016 15:12
-
-
Save nmurzin/19834d008ee8ff3cf3a731f25deed70d to your computer and use it in GitHub Desktop.
How to transfer jquery to bottom of the page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> | |
<script> | |
// Fallback code for the jQuery inline scripts on pages: | |
if (window.jQuery === undefined) { | |
window.jQueryReadyHandlers = []; | |
window.$ = window.jQuery = function (callback) { | |
window.jQueryReadyHandlers.push(callback); | |
return window.$; | |
}; | |
window.$.ready = window.$; | |
} | |
</script> | |
<!-- ...some head items --> | |
</head> | |
<body> | |
<!-- ...some page content --> | |
<script> | |
// some onReady-handlers | |
$(function(){ | |
console.log('First callback'); | |
}); | |
jQuery(document).ready(function(){ | |
console.log('Second callback'); | |
}); | |
</script> | |
<!-- ...some page content --> | |
<script src="//js/jquery.min.js"></script> | |
<script> | |
jQuery(window).load(function(){ | |
if(window.jQueryReadyHandlers) { | |
$.each(window.jQueryReadyHandlers, function(index,func){ | |
$(func); | |
}); | |
} | |
}); | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment