Answer the question
In order to leave comments, you need to log in
Should I split css/js for different pages?
Does it make sense to divide on the server into different pages, for example, using is_product()
functions, js and css code, will this optimize the speed of work, or due to the fact that new files will be constantly loaded, instead of loading 1 time and flying into the cache, it on the contrary will put spokes in wheels?
Answer the question
In order to leave comments, you need to log in
In general, it's worth it.
But it mostly depends on your specific case. How much code is shared across all pages? How many are unique for each page type? How many are unique for each page? What is the user behavior pattern? Will it visit all pages of the site or only pages of one type? Do users visit the site only once, or do they keep coming back? From what devices and with what speed of the Internet do they come to you? How is the deployment process built? What are your hosting rates? How often and what do you change in the source code? How will you invalidate the cache? And there are many more issues to consider.
Everything can be bundled into one huge bundle. Then the initial download will be longer, especially noticeable on a slow Internet. But page navigation will be faster, and server load will be less. But when changing, say, the color of one button, the user will have to re-download the entire bundle. And vice versa. You can go the other way: crush everything into as small pieces as possible. (For example, take out all the code for some modal separately) and load each chunk only at the moment when it is needed. So the initial load will be much faster, but the reaction to user actions will be slower.
In the general case - splitting the site code into pieces and giving them away in parts - is worth it. But I'll die. And how exactly to divide - depends on your case.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question