In jQuery, the common practice is to place functions in this container:
$(document).ready(function(){};
Most of the time this is perfect, because it will execute as soon as the DOM is loaded, and you won’t see a flicker of ‘before’ content. However I was creating a function to resize two elements to the same height, and one of them contained a dynamically loaded image, and there was no way to know or set the ‘height’ attribute. Because of this the jQ function would fire before the height of the image could be determined and the element would cut off the image once it had.
So in this case you should use the window.onload call instead. (Full function below) Read more »