I have a script that looks like this:
$(function(){
var backgroundImg = document.querySelector(".image-selector");
var bmyObject = {
backImgNaturalWidth : backgroundImg.naturalWidth,
/*
Rest of the object that is okay
*/
};
/*Rest of my script*/
}
The issue is that sometimes naturalwidth is taken properly and sometimes it is 0 which breaks rest of the script that makes calculations with this number involved. Any ideas why this happens or how to solve would be great.