I've inherited a Class-based PHP site where every page of the site is its own Class. The index.php
handles what page you view based on the p
parameter, and then calls that specific Class. For example, the search page of the site is simply mysite.com/?p=search
One of the first lines in the index.php
calls an Autoload.php
file which does an include
of every single Class-based page of the site. This means that no matter which page you are on, the script is loading every single other page/class.
My questions:
- There is NO connection between those pages/classes, so is it really necessary to load all of them on every pageload?
- Does it slow down the script having to
include
over 50 pages/classes on every pageload or is it negligible? - If so, then shouldn't I do an if-based check to determine which page/class I should load based on the
p
parameter and ONLY load that one rather than load every page on every pageload? - Or is there some other potential downside of doing that that I'm not aware of?