JSFiddle - React, Tailwind, and code Playground

HTML

<body>
</body>

CSS

body.loading, body.loading input, body.loading a { cursor: wait; }
body {width:200px;height:200px;background:blue}
body.loading {background:red}

JavaScript

var loadingLayer = {
        step: 0,
        add: function(){
            this.step += 1;
//didn't know how to call checkState() automatically after any other call
            this.checkState();
        }, remove: function(){
            this.step -= 1;
            this.step < 0 && (this.step=0);
            this.checkState();
        }, clear: function(){
            this.step = 0;
            this.checkState();
        }, checkState: function(){
            if (this.step === 0){
                $("body").removeClass("loading");
            } else {
                $("body").addClass("loading");
            }
        }
    };
    $(document).ajaxStart( function(){
        loadingLayer.add();
    });
    $(document).ajaxComplete(function(){
        loadingLayer.remove();
    });    
    $(document).ready(function(){
        $("body").load("http://www.enapupe.com.br/sleep.php");
    });