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");
        if (isNaN(el.value))
            el.value = old;
    }).queue();

    console.time("test");
});

Function.prototype.queue = function () {
    var scr = new Image(), fn = this;
    scr.onload = function () {
        scr.onload = null;
        fn();
    }
    scr.src = "data:image/png;base64,"
        +"iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABGdBTUEAALGP"
        +"C/xhBQAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9YGARc5KB0XV+IA"
        +"AAAddEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIFRoZSBHSU1Q72QlbgAAAF1J"
        +"REFUGNO9zL0NglAAxPEfdLTs4BZM4DIO4C7OwQg2JoQ9LE1exdlYvBBeZ7jq"
        +"ch9//q1uH4TLzw4d6+ErXMMcXuHWxId3KOETnnXXV6MJpcq2MLaI97CER3N0"
        +"vr4MkhoXe0rZigAAAABJRU5ErkJggg==";
    
}