basic 'php include' question
Copy link to clipboard
Copied
I decided to use php includes for my static html website. The footer.php includes the javascript, but I don't need certain scripts to load unneccesarily on different pages, obviously. It's been awhile but, what are my options to avoid this? Thanks
Copy link to clipboard
Copied
Anything in the include will know of the parent it is called in and vice versa but in terms of your scripting it needs to be structured so that functions and targeted code only runs when those elements exist anyway. Very wasteful (and many do it) to have say a slider plugin running looking for a specific div every single page load. Even simple if conditions to check if an element exists first is better than having everything run.
Until HTTP2 is globally in use and all the mainstream it is still best to also ensure you are not loading many scripts to reduce the load.

