Last active
October 5, 2015 00:48
-
-
Save devfred/2726369 to your computer and use it in GitHub Desktop.
javascript: jQuery dom ready before jquery is loaded
This file contains 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
/* This snippet allowes function to user jQuery dom ready before jquery is loaded */ | |
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; | |
})(); | |
/* | |
Use the following to call the functions | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> | |
<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