I know the solution from this question: Get the real width and height of an image with JavaScript? (in Safari/Chrome)
But I want to know if there's a simpler way to find the image's original dimensions if you are CERTAIN that the image has already been loaded.
In my code, I already use:
$("<img/>").attr("src", $(img).attr("src")).load(function() {
imageWidth = this.width;
imageHeight = this.height;
});
But this is useful when you aren't sure if the images are loaded or cached.
Is there another method that might be significantly faster in execution when you don't have to worry about the images being cached or loaded?
I want to detect the image's true dimensions on resizing the window $(window).resize(function(){});
.
Since this event fires really quickly, I want to make sure I use the most efficient method rather than the most careful one.