I think this may be in the proper forum, but if not then can one of the moderators help me move it please.
in thinking of how to make a page, any web page, load faster… Is it best to all have all the external file inside or linked. For example with php, js, and css should you link to external files or put all the contents in the file internally?
Does linking many files create more http header requests, which slow down the page load though?
I mean, I know if one has an external file, such as css or a script, that is shared by every or most pages then it should be external as the other pages can rely on a caches copy.
But in general, does linking to files and imuding files within those linked external files cause a slower page load?
Potentially, wouldn’t it be best to then have one external file per language? So, all the cc goes in one main.css file and all the js in a main.js file?
I hope I explaied my question enough and I hope someone can help me.I would appreciate any help greatly and if you have a y questions, comments, or concerns please let me know
Any time people are visiting more than one page on your site (which you should hope they will be), you should externalise any resource you can, such as stylesheets and scripts - whatever happens on the first page, all subsequent pages will load more quickly because those files will be cached.
In general you should minimise the number of HTTP requests, which will reduce the latency and lag. Every resource you request from a server adds a very small amount of time, so you should try to keep all styles in a single file, and all scripts in a single file, as far as possible. Obviously, if you have a lot of styles or scripts that are only needed by a few pages, you might be better to keep these in a separate file, as the extra HTTP request will be easily outweighed by the savings from visitors who don’t go to those pages.