JSFiddle - React, Tailwind, and code Playground

by AndyE

HTML

<input type="text">

JavaScript

var tArr = {};
console.time = console.time || function (n) {
    if (String(n))
        tArr[n] = +new Date();
}
console.timeEnd = console.timeEnd || function (n) {
    if (String(n))
        console.log(n + ": " + (+new Date() - tArr[n]) + "ms");
}
    
$("input").keydown(function () {
    var el = this,
        old = this.value,
        img = new Image();
    
    (function () {
        console.timeEnd("test");
        console.log(el.value);
        if (isNaN(el.value))
            el.value = old;
    }).queue();

    console.time("test");
});
$("body").keydown(function () {
    console.log("body");
});

(function () {
    var fnQ = [],
        scr = document.createElement("script"),
        hd  = document.getElementsByTagName("head")[0];

    scr.onreadystatechange = function () {
        scr.onreadystatechange = null;
        for (var i=fnQ.length-1; i>=0; i--)
            fnQ.shift()();
        
        hd.removeChild(scr);
        scr = document.createElement("script");
        scr.onreadystatechange = arguments.callee;
    }
    
    Function.prototype.queue = function () {
        fnQ.push(this)
            
        if (!scr.parentNode)
           hd.appendChild(scr);
    }
})();