-
-
Save furf/737468 to your computer and use it in GitHub Desktop.
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
(function(j,q,u,e,r,y){if(typeof(jQuery)=='undefined'){(q=j.createElement(q)).type='text/javascript';if(r){q.async=true;}q.src='//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js';u=j.getElementsByTagName(u)[0];q.onload=q.onreadystatechange=(function(){if(!e&&(!this.readyState||this.readyState=='loaded'||this.readyState=='complete')){e=true;y();q.onload=q.onreadystatechange=null;u.removeChild(q);}});u.appendChild(q);}else{y();}})(document,'script','head',false,false,(function(){$(function(){ | |
/* code goes here */ | |
});})); | |
// readable: | |
(function (j, q, u, e, r, y) { | |
if (typeof(jQuery) == 'undefined') { | |
(q = j.createElement(q)).type = 'text/javascript'; | |
if (r) { q.async = true; } | |
// dont need http|https - /1/ means latest 1.x version | |
q.src = '//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js'; | |
u = j.getElementsByTagName(u)[0]; | |
// onload event for callback | |
q.onload = q.onreadystatechange = (function () { | |
// first fire when completely loaded and parsed & check if this happened before | |
if (!e && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) { | |
e = true; | |
// execute your jquery code now | |
y(); | |
// IE memory leak protection | |
q.onload = q.onreadystatechange = null; | |
u.removeChild(q); | |
} | |
}); | |
u.appendChild(q); | |
} | |
else { | |
// looks like jquery is already loaded - just execute code right away | |
y(); | |
} | |
// async callback | |
})(document, 'script', 'head', false, false, (function () { | |
$(function(){ | |
/* code goes here */ | |
}); | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment