JSFiddle - React, Tailwind, and code Playground

HTML

<img src="http://environmentalgeography.files.wordpress.com/2010/02/nature_by_abhishekultimatum.jpg?q=45465d151556g12">

JavaScript

getImageSize($('img'), function(width, height){
    alert('size is: ' + width + 'x' + height);
});

function getImageSize(img, callback){
    img = $(img);
    
    var wait = setInterval(function(){        
        var w = img.width(),
            h = img.height();
        
        if(w && h){
            done(w, h);
        }
    }, 0);
    
    var onLoad;
    img.on('load', onLoad = function(){
        done(img.width(), img.height());
    });
    
    
    var isDone = false;
    function done(){
        if(isDone){
            return;
        }
        isDone = true;
        
        clearInterval(wait);
        img.off('load', onLoad);
        
        callback.apply(this, arguments);
    }
}