Reputation: 19868
I'm trying to optimize the loading time of my webpages, both on the first time and from cache. But I still ask the browser to re-validate all resources to make sure I will never have a weird display or an update problem due to the cache.
So currently the loading of my page always needs two requests: one for the HTML file, one for the CSS file before anything is displayed.
For both of this files, the waiting time is like 150ms while the transfer is like 5ms, which is very low.
So I'm thinking about always embeding my mais css file into the web page.
This isn't the academic way to do, but I think this would multiply the loading speed by 2, making only one request needed to load the page.
Is there a reason why I should not do that ?
Upvotes: 0
Views: 56
Reputation: 23558
you can get the best of both worlds if you set up a build script for your website.. so basically in your local file system you can keep your css files separated, making it more portable and easier to maintain etc.. but at the same time your build script embeds your css and other static files (ie js) into your html page to avoid precisely what you talked about (ie redundant connections to the server)..
Upvotes: 2
Reputation: 5742
Portability, the ability of changing one .css file and change multiple .html files with a reference to that css.
However, if your css is only used in that page, I think is a good reason to include it in the same file.
Upvotes: 1