I have a page where I want to display different images based on the time of day.
How I have this working now is that attached to the jquery ready listener I have a function that selects all image elements and changes their source based on the hour. Each img tag has a default src specified in the html, just in case the user has js deactivated or whatever.
With this method, however, I am paranoid that the browser starts loading the default image, then proceeds to load the time-specific image, causing unnecessary overhead.
So my question is this: if I change the img source in the jquery ready event, does the img src get changed before the browser starts loading images.
Thanks for any and all responses. I apologize if this is a duplicate question, but there are a million questions regarding the nuances of the jquery ready event.
I think the ready listener starts running as soon as all the html loads, meaning it will not wait for bg to load and ready will run. So depends on timing you can have default loading then getting switched.
Perhaps you can leave out the src for the image or the css for the bg and only add it with jquery in ready().
For people disabling js, you can have the default load in a noscript block