Measuring Image Widths in JavaScript (Carefully!)

Let’s say you want to find an on the page and find out how wide it is in JavaScript. Maybe you need to make some choices based on that width (or height, or both) You can definitely do that. The DOM will even give you a variety of dimensions to choose from depending on what you need. There is definitely a catch though.

Here’s the image:
<img src=”image.jpg" alt="an image">
And here’s us selecting it, by finding the first …

Measuring Image Widths in JavaScript (Carefully!) is a post from CSS-Tricks