Skip to content

Instantly share code, notes, and snippets.

@Iristyle
Created March 15, 2012 16:43
Show Gist options
  • Save Iristyle/2045205 to your computer and use it in GitHub Desktop.
Save Iristyle/2045205 to your computer and use it in GitHub Desktop.
Standard document onReady script queue
<!-- concepts from http://samsaffron.com/archive/2012/02/17/stop-paying-your-jquery-tax -->
<!-- for head -->
<script type='text/javascript'>
window.$ = (function() {
var q = [], f = function (cb) {
q.push(cb);
};
f.attachReady = function ($) {
$(function () {
$.each(q, function(i, f) {
f();
});
q.length = 0; // clear it, just in case
});
return $;
}
return f;
})();
</script>
<!-- at end of page -->
<script type="text/javascript">
$.noConflict();
$ = $.attachReady(jQuery);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment