Head HTML
Head HTML for every page is loaded in two places:
- The core HeadHtml.php file, which loads the core libraries and CSS stylesheets needed for all pages, and inserts the CSRF token.
- Each page's own <head> tag, where page-specific content is loaded.
In production, a single css file, productionstyles.css, is loaded (to reduce HTTP request overhead).
In test environments, the main CSS files used by most pages are loaded individually.
Code Hierarchy
Base path: src/Core/Includes/Head/
Path (relative to base path) | Notes |
HeadHtml.php |
The main file included by all pages, via the StaticContent class in src/Core/StaticContent.php.
This file loads all commonly used CSS/JS, and decides whether to use test or production versions. |
Imports/HeadScriptImports.php | Included once by HeadHtml.php to add all commonly used JS scripts to the head of each page, via the configuration_head_scripts database table. |
Imports/HeadTestCssImports.php |
If the WebConfig::USE_PRODUCTION_CSS value is set to true, this file is included once by HeadHtml.php to add each of the individual CSS files to the page head.
Otherwise, HeadHtml.php loads the production CSS, productionstyles.css, which reduces HTTP overhead. |
The configuration_head_scripts database table
Within Imports/HeadScriptImports.php, the scripts to include onto each page are retrieved from the configuration_head_scripts database table. The contents of this table are cached with the SITE:::WEBSERVER:::HEADSCRIPTSCONFIGURATION redis key.
The scripts (and some CSS files also present in the table) are loaded in the exact order specified by the loading_order column of the table, to prevent any loading conflicts.