JSFiddle - React, Tailwind, and code Playground
by peterbenoit
HTML
<div id="highlight">Some text</div>
<script src="http://codeorigin.jquery.com/jquery-2.0.3.min.js" defer></script>
JavaScript
var callbacks = [], iterate = 50;
//Temp $
function $(cb) {
callbacks.push(cb);
return $;
}
//$ monitor
(function waitFor$() {
console.log("Trying " + iterate);
if(!iterate){
console.log("Timeout");
return;
}
if(window.jQuery) {
console.log("Tada");
callbacks.forEach(function(cb){
jQuery(cb);
});
}
else {
iterate--;
console.log("No luck so far");
setTimeout(waitFor$, 100);
}
}())
//jQuery is not defined here
console.log(typeof window.jQuery);
$(function(){
$("#highlight").css("background-color", "red");
});
//and here
console.log(typeof window.jQuery);
$(function(){
$("#highlight").text("Modified using jQuery.");
});