JSFiddle - React, Tailwind, and code Playground
by h1mueller
HTML
<a href="#" onclick="checkHighCharts();">Check Highcharts</a>
<div id="log"></div>
<script type="text/javascript">
var widget=(function() {
// Localize jQuery variable
var jQuery;
var domain="example.com";
/******** Load jQuery if not present *********/
var script_tag = document.createElement('script');
script_tag.setAttribute("type","text/javascript");
script_tag.setAttribute("src","http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.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($) {
jQuery('#log').append('Main - jQuery has loaded<br />');
loadHighcharts();
});
}
function checkHighCharts(){
if (typeof window.Highcharts === 'undefined') {
jQuery('#log').append('checkHighCharts - No highcharts<br />');
}
else{
jQuery('#log').append('checkHighCharts - Highcharts exists<br />');
}
}
function loadHighcharts(){
var script_tag2 = document.createElement('script');
script_tag2.setAttribute("type","text/javascript");
//script_tag2.setAttribute("src","http://highcharts.com/js/testing.js");
//script_tag2.setAttribute("src","http://code.highcharts.com/highcharts.src.js");
...