JavaScript / jQuery – window resize complete

var duration;

var timeout = false;

var ms = 200;

$(window).resize(function() {

    duration = new Date();
    
    if (timeout === false) {
    
        timeout = true;
        setTimeout(resizeStopEvent, ms);
    }
});

function resizeStopEvent() {

    if (new Date() - duration < ms) {
    
        setTimeout(resizeStopEvent, ms);
    }
    else {
    
        timeout = false;
        
        // do anything in resize end :)
        // ...
    }               
}

JavaScript ES5/ES6 sleep-Funktion

// ES5
function sleep(ms) {
    return new Promise(function(resolve) {
        return setTimeout(resolve, ms);
    });
}

// ES6
function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}

// use it
sleep(5000) // 5 Sekunden