I think I answered most of the questions other than where the error is happening, which as others have said, is in the console, about once every second.
To me that JavaScript also looks wrong, because the width and height values being returned are not in scope, having been defined in the function. So I’m not sure how that code works for anybody on any browser.
Same here, also happening on my site.
On latest Safari, on a Macbook Pro (retina).