JSFiddle - React, Tailwind, and code Playground

by Jake

HTML

<img src="https://assets.gitlab-static.net/uploads/-/system/user/avatar/2852881/avatar.png?width=23" id="i">

JavaScript

const ball = document.getElementById('i');

const checkImgSize = el => {
    console.log(`natural height and width: ${el.naturalHeight} - ${el.naturalWidth}`);
    console.log(`client height and width: ${el.clientHeight} - ${el.clientWidth}`);
};

if( ball.loaded )
    checkImgSize(ball);
else 
    ball.addEventListener('load', function(){ checkImgSize(this) }, { once: true });