| @@ -7,8 +7,9 @@ | ||
| 7 | 7 | class berqPageOptimizer { |
| 8 | 8 | public $page_slug = null; |
| 9 | 9 | public $page_url = null; |
| 10 | 10 | public $settings = null; |
| 11 | + public $early_head_html = ''; | |
| 11 | 12 | |
| 12 | 13 | function __construct() { |
| 13 | 14 | |
| 14 | 15 | if ($this->settings === null) { |
| @@ -1192,9 +1193,9 @@ | ||
| 1192 | 1193 | |
| 1193 | 1194 | function store_cache($buffer) { |
| 1194 | 1195 | // Define the cache directory |
| 1195 | 1196 | $cache_directory = bwp_get_cache_dir(); |
| 1196 | - $url = $this->page_url; | |
| 1197 | + $url = bwp_canonicalize_page_url($this->page_url); | |
| 1197 | 1198 | |
| 1198 | 1199 | // Create the cache directory if it doesn't exist |
| 1199 | 1200 | if (!file_exists($cache_directory)) { |
| 1200 | 1201 | mkdir($cache_directory, 0755, true); |
| @@ -1337,9 +1338,10 @@ | ||
| 1337 | 1338 | |
| 1338 | 1339 | $prelaod_html .= '>'.PHP_EOL; |
| 1339 | 1340 | } |
| 1340 | 1341 | |
| 1341 | - $buffer = berqwp_prependHtmlToHead($buffer, $prelaod_html); | |
| 1342 | + /* $buffer = berqwp_prependHtmlToHead($buffer, $prelaod_html); */ | |
| 1343 | + $this->early_head_html .= $preload_html; | |
| 1342 | 1344 | |
| 1343 | 1345 | } |
| 1344 | 1346 | |
| 1345 | 1347 | |
| @@ -1550,13 +1552,15 @@ | ||
| 1550 | 1552 | $critical_css->forceInclude($this->settings['force_include_critical_css']); |
| 1551 | 1553 | $critical_css = $critical_css->process_css($buffer); |
| 1552 | 1554 | $critical_css = sprintf('<style data-berqwp-exclude id="berqwp-used-css">%s</style>', $critical_css); |
| 1553 | 1555 | |
| 1554 | - $buffer = berqwp_prependHtmlToHead($buffer, $critical_css); | |
| 1556 | + /* $buffer = berqwp_prependHtmlToHead($buffer, $critical_css); */ | |
| 1557 | + $this->early_head_html .= $critical_css; | |
| 1555 | 1558 | $buffer = $this->delay_styles($buffer); |
| 1556 | 1559 | |
| 1557 | 1560 | } |
| 1558 | 1561 | |
| 1562 | + $buffer = berqwp_earlyHeadHtml($buffer, $this->early_head_html); | |
| 1559 | 1563 | |
| 1560 | 1564 | $buffer = $this->restore_template_scripts( $buffer, $template_placeholders ); |
| 1561 | 1565 | |
| 1562 | 1566 | $script = apply_filters('berqwp_photon_before_closing_body', $script); |