JSFiddle - React, Tailwind, and code Playground
HTML
<script>
if (typeof jQuery == 'undefined') {
// jQuery is not loaded
alert('jQuery is not loaded');
var script = document.createElement('script');
script.type = "text/javascript";
script.src = "http://code.jquery.com/jquery-1.9.1.js";
document.getElementsByTagName('head')[0].appendChild(script);
var script_ui = document.createElement('script');
script_ui.type = "text/javascript";
script_ui.src = "http://code.jquery.com/ui/1.10.3/jquery-ui.js";
document.getElementsByTagName('head')[0].appendChild(script_ui);
} else {
// jQuery is loaded
alert('jQuery is loaded');
if (typeof jQuery.ui !== 'undefined') {
// ui plugin exists
alert('ui plugin exists');
} else {
// ui plugin DOES NOT exist
//alert('ui plugin DOES NOT exist');
var script_ui = document.createElement('script');
script_ui.type = "text/javascript";
script_ui.src = "http://code.jquery.com/ui/1.10.3/jquery-ui.js";
document.getElementsByTagName('head')[0].appendChild(script_ui);
}
}
</script>
<body>
<p>Not loaded yet.</p>
<input type="text" id="datepicker" /></p>
</body>
<script>
jQuery(document).ready(function() {
// Handler for .ready() called.
jQuery(function() {
jQuery( "#datepicker" ).datepicker();
});
});
</script>
JavaScript
/*jQuery(document).ready(function () {
jQuery("p").text("The DOM is now loaded and can be manipulated. Typeof jQuery: " + (typeof jQuery));
jQuery("#datepicker").datepicker();
});*/