• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

basic 'php include' question

Explorer ,
Jun 29, 2020 Jun 29, 2020

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

Views

183

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 27, 2020 Aug 27, 2020

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines