JSFiddle - React, Tailwind, and code Playground

JavaScript

// wait for 3 + (0..2) seconds
setTimeout(function () {
    $(document.body).append($("<strong>hello</strong>"));
}, 3000 + 2000 * Math.random());

function waitFor(test, interval) {
    var dfd = $.Deferred();
    var count = 0;
    var id = setInterval(function () {
        console.log(count++);
        var val = test();
        if (undefined !== val) {
            clearInterval(id);
            dfd.resolve(val);
        }
    }, interval);
    return dfd.promise();
}

function waitForEl(selector, interval) {
    return waitFor(function () {
        var els = $(selector);
        return (els.length > 0) ? els : undefined;
    }, interval);
}

waitForEl("strong", 100).then(function (strong) {
    strong = strong.first();
    console.log(strong, strong.height());
});