Home > database >  How to stop a CSS file from loading again?
How to stop a CSS file from loading again?

Time:07-07

I have a very simple site and all the CSS for it is written in one file, so whenever any page is requested the CSS file is loaded. So I was wondering if there is someway, that I can tell the browser to use the same file it loaded a second ago instead of requesting it again.

CodePudding user response:

I assume you have the css loaded externally then? I don't believe there is a way to natively do that unfortunately. But, if you're proficient in javascript, I suppose you could save all of the css file as a string using the localStorage property in the browser. Then request the data you want loaded specifically per site.

Local storage persists after the browser is closed, so it would only need to be loaded once!

  • Related