JSFiddle - React, Tailwind, and code Playground

by malonso

JavaScript

var widget=(function() {
    
// Localize jQuery variable
var jQuery;

var domain="example.com";

/******** Load jQuery if not present *********/
if (window.jQuery === undefined || window.jQuery.fn.jquery !== '1.7.1') {
    var script_tag = document.createElement('script');
    script_tag.setAttribute("type","text/javascript");
    script_tag.setAttribute("src","http://"+domain+"/js/jquery.js");
    if (script_tag.readyState) {
      script_tag.onreadystatechange = function () { // For old versions of IE
          if (this.readyState == 'complete' || this.readyState == 'loaded') {
              scriptLoadHandler();
          }
      };
    } else { // Other browsers
      script_tag.onload = scriptLoadHandler;
    }
    // Try to find the head, otherwise default to the documentElement
    (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_tag);
}

/******** Called once jQuery has loaded ******/
function scriptLoadHandler() {
    // Restore $ and window.jQuery to their previous values and store the
    // new jQuery in our local jQuery variable
    
    jQuery = window.jQuery.noConflict(true);
    // Call our main function
    main(); 
}

/******** Our main function ********/
function main() { 
    jQuery(document).ready(function($) { 
        
    });
}

function loadJS(){
    var jsFiles=['/randomJS1.js','/randomJS2.js'];
    var jsFilesCount=jsFiles.length;//
    
    for(var i=0;i<jsFilesCount;i++){
        var curFile='http://'+domain+jsFiles[i];
        var js_link = jQuery("<script>", {
            type: "text/javascript",
            src: curFile
        });
        js_link.appendTo(document.getElementsByTagName('head')[0] || document.documentElement);
    }    
}
    
function checkHighCharts(){
    if (typeof window.Highcharts === 'undefined') {
        alert("No highcharts");     
    }
    else{
        alert("Found highcharts");
    }
}

    
});