function myJQueryCode() {
$(document).ready(function () {
$("#div1").replaceWith("JQuery is loaded");
});
}
if(typeof jQuery=='undefined') {
var headTag = document.getElementsByTagName("head")[0];
var jqTag = document.createElement('script');
jqTag.type = 'text/javascript';
jqTag.src = '//code.jquery.com/jquery-2.0.3.min.js';
jqTag.onload = myJQueryCode;
headTag.appendChild(jqTag);
} else {
alert('You are here')
myJQueryCode();
}
function yourFunctionToRun(){
//Your JQuery goodness here
}
function runYourFunctionWhenJQueryIsLoaded() {
if (window.$){
//possibly some other JQuery checks to make sure that everything is loaded here
myJQueryCode();
} else {
setTimeout(function() {runYourFunctionWhenJQueryIsLoaded()}, 50);
}
}
runYourFunctionWhenJQueryIsLoaded();
if(typeof jQuery=='undefined') {
alert('Houston we have a problem');
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!