Get Image Size in Javascrip

var getImageSize = function(imgSrc){
       var imageSize = '';
        var obj = new XMLHttpRequest();
        obj.open('HEAD', imgSrc, true);
        obj.onreadystatechange = function(){
            if ( obj.readyState == 4 ) {
                if ( obj.status == 200 ) {
                    //alert('Size in bytes: ' + obj.getResponseHeader('Content-Length'));
                    imageSize = obj.getResponseHeader('Content-Length');
                } else {
                }
            }
        };
        obj.send(null);
        return imageSize;
    };