Skip to content

Instantly share code, notes, and snippets.

@avuori
Last active September 4, 2015 13:28
Show Gist options
  • Save avuori/d592ef0a6f83514fd29e to your computer and use it in GitHub Desktop.
Save avuori/d592ef0a6f83514fd29e to your computer and use it in GitHub Desktop.
(function(jqueryUrl, callback) {
if (typeof jqueryUrl != 'string') {
jqueryUrl = 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js';
}
if (typeof jQuery == 'undefined') {
var script = document.createElement('script');
var head = document.getElementsByTagName('head')[0];
var done = false;
script.onload = script.onreadystatechange = (function() {
if (!done && (!this.readyState || this.readyState == 'loaded'
|| this.readyState == 'complete')) {
done = true;
script.onload = script.onreadystatechange = null;
head.removeChild(script);
callback();
}
});
script.src = jqueryUrl;
head.appendChild(script);
}
else {
callback();
}
})(false, callback);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment