Will a browser still lazy load a script if it is already in the browser cache?

caching, html, javascript, lazy-loading

Solution

I'm not basing this on hard figures, but I think it safe to say that about 75~80% of the browsers being used today do a pretty good job caching the scripts. AFAIK, there are ways to force browsers not to use the cached scripts, but seeing as that's not what you want, that doesn't matter.

Yes, most of the browsers will, in fact, refer to the cahced scripts, and not request the files over and over again. Of course, some people are concerned about their privacy, and will only browse the web in anonymous/incognito-mode (aka porn mode). This causes the browser to clear the cache when the browser window is closed. Why would you care? Well, I for one, find this very useful when developing my JS scripts. hard-refreshing is something like ctrl+c. We've all grown the habbit of pressing those two keys 4~5 times, just to make sure. I've noticed that my co-workers do the same thing with ctrl+F5, too...

Problem

I'm using lazyload.js to lazy load several scripts. Now I was thinking of just using a site-wide include which tells lazyload.js to load all scripts used on my site. Then I could let the browser decide if any of these scripts is already in the cache or not (and to load them if necessary). That saves me from having to do testing in js whether something is already loaded (and I'm willing to accept the overhead of a couple of extra requests being made). Would it work that way, or am I overlooking something?

Original source