JSFiddle - React, Tailwind, and code Playground

by nrabinowitz

JavaScript

function test1() {
    console.log("throwing 1...");
    throw "Test Error 1";
}
function test2() {
    console.log("throwing 2...");
    throw "Test Error 2";
}
function test3() {
     console.log("throwing 3...");
     throw "Test Error 3";
}
function test4() {
      console.log("throwing 4...");
      throw "Test Error 4";
}

(function () {

    if (document.addEventListener) {
        document.addEventListener('readyEvents', test1, false);
        document.addEventListener('readyEvents', function() {
            try { test4() } catch (e) { console.log(e) }
        }, false);

        fireReady = function () {
            var readyEvent = document.createEvent('UIEvents');
            readyEvent.initEvent('readyEvents', false, false);
            document.dispatchEvent(readyEvent);
        };

        document.addEventListener('DOMContentLoaded', fireReady, false);
        document.addEventListener('DOMContentLoaded', test2, false);
        window.addEventListener('load', test3, false);
    }
    
})();