So, recently, after accruing quite a few js and css files, I began thinking about all of the http calls I was making.
Since I use PHP inlcude for the page headers and footers, every page was calling every script which was really inefficient. So I started using conditional statements in the pages with php to call only the needed files.
Then I thought, hey, wouldn’t it be smarter to cut down on all of these http calls (even now every page has more than a few external js or css files) by making one huge css.php, and one huge js.php, and just include them in the header and footer respectively, and use conditional statements within those files?
The end result would be that those large files would be processed server side, and each page would get its css directly in the head and jss directly in the bottom of the body, with all of the code it needs and no more than that.
Is there any reason not to do this? Any thoughts in general on this idea? Is everyone else already doing this and I just missed the boat?
I would have liked to award this answer to Marc, but he didn’t formally answer and everyone else was off base. Maybe I didn’t ask the question clearly enough.
In any event, the answer is that this shouldn’t really be done, as though it is efficient that each page gets only the css and js it needs and extraneous HTTP requests are avoided, the resulting files are always unique for each page and thus, not practically cache-able.
Thanks for everyone’s input!