Although it should really matter, try using .clientWidth
instead of .width
This answer explains that
In the case of an IMG element, this will get the actual dimensions of the visible image.
HTML
<img id="image" width="0" height="100" src="http://placehold.it/100x100"/>
JavaScript
var img = document.getElementById('image'); // which is an <img> element
if (img.clientWidth > 0) {
// I get here in Chrome, width is correct
console.log('Do something if greater than 0')
}
else {
// I get here in Safari, width is 0
console.log('Do something else if not greater than 0')
}
Here's a quick Codepen link to show it working in both browsers