JSFiddle - React, Tailwind, and code Playground

by bridget_kilgallon

HTML

//example of the webpage that's importing the scripts
<html>
<head>
<title>Example</title>
<script type="text/javascript" src="importJs.js"></script>
</head>
<body>
this is a test.
</body>
</html>

JavaScript

//the importJs.js script
window.addEventListener('load',importExtJs,false);

function importExtJs() {
    //enter the urls of each script
    var scriptArray = ['http://yoursite.com/script1.js',
                  'http://yoursite.com/script2.js',
                  'http://yoursite.com/script3.js'];

    var scr;
    var head = document.getElementsByTagName('head')[0];
    if (head) {
        for (var i=0; i<scriptArray.length; ++i) {
            scr = document.createElement('script');
            scr.setAttribute('type','text/javascript');
            scr.setAttribute('src',scriptArray[i]);
            head.appendChild(scr);
        }
    }
}