JSFiddle - React, Tailwind, and code Playground

by ArchersFiddle

JavaScript

// we need to add the script element this way with jsfiddle.  Just add it normally in your head.
var s = document.createElement("script");
s.setAttribute("data-fallback", "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.js");
document.querySelector("head").appendChild(s);


var scripts = document.querySelectorAll("script[data-fallback]");

[].forEach.call(scripts, function(script) {
    var listener = script.addEventListener("error", function(e) {
    	var newScript = document.createElement("script");
        
        // this is just for demo purposes...
        newScript.addEventListener("load", function() {
        	console.log("fallback script loaded");
        });
        
        newScript.setAttribute("src", script.getAttribute("data-fallback"));
        document.querySelector("head").appendChild(newScript);
    });
});

s.src = "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.fail";