I am working on revamping an older CMS and I am wondering how I should handle things like multiple css and javascript files that only need to be included on certain pages.
Let's say for example I have the following pages:
- services.php -> requires jquery-1.4.2.min.js
- index.php -> no javascript required
However, on each of these pages, I am including a file from an includes folder
include 'includes/inc_header.php';
This file contains code like the following:
<!doctype ...>
<html>
<head>
<script type="text/javascript">...
Here is where I run into the problem. I have thought about using an array and looping through and printing each element required. This way each page could simply add the scripts they need to the array. I thought this might get very complicated very fast however.
Can anyone give me a good approach to solving this problem?