JSFiddle - React, Tailwind, and code Playground

by Paulpro

HTML

<body>
    <div id="msg">Not Started</div>
    <button>jQuery</button>
    <a href="#">javascript</a>
</body>

JavaScript

(function(){
    
    function addSecs(d, s) {return new Date(d.valueOf()+s*1000);}

    var start, end;
    
    document.getElementsByTagName('a')[0].onclick = function(){
        doRun(function(){
             do {start = new Date();} while (end-start > 0);
             document.getElementById('msg').innerHTML = 'Finished JS';   
        });
        return false;
    };
    
    function doRun(cont){
        document.getElementById('msg').innerHTML = 'Processing JS...';
        start = new Date();
        end = addSecs(start,5);
        setTimeout(cont, 1);
    }
        
    $(function() {
            $('button').click(function(){
                (function(cont){
                    $('div').text('Processing JQ...');  
                    start = new Date();
                    end = addSecs(start,5);
                    setTimeout(cont, 1);
                })(function(){
                    do {start = new Date();} while (end-start > 0);
                    $('div').text('Finished JQ');   
                })
            });
    });

})();