PluginProbe
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript / 4.1.19
BerqWP – All-In-One Optimization for Core Web Vitals, Cache, CDN, Images, CSS & JavaScript v4.1.19
4.1.19 4.1.18 4.1.17 4.1.16 4.1.15 4.1.14 4.1.13 4.1.12 4.1.11 4.1.10 4.0.30 4.0.29 4.0.28 4.0.27 4.0.26 4.0.24 4.0.25 4.0.23 4.0.22 4.0.21 4.0.19 4.0.18 4.0.17 4.0.16 1.9.3 All 173 releases
← All changes | inc/photon/class-berqPageOptimizer.php +18 -8 4.0.16 → 4.1.19 View file →
@@ -1,14 +1,15 @@
1 1 <?php
2 2 if (!defined('ABSPATH')) exit;
3 3
4 4 use BerqWP\Cache;
5 -use voku\helper\HtmlDomParser;
5 +use BerqWP_Deps\voku\helper\HtmlDomParser;
6 6
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) {
@@ -725,8 +726,9 @@
725 726 bubbles: true,
726 727 cancelable: true
727 728 });
728 729 document.dispatchEvent(event);
730 + document.dispatchEvent(new Event('readystatechange'));
729 731 window.dispatchEvent(new Event('load'));
730 732
731 733
732 734 // Create a new resize event
@@ -1191,9 +1193,9 @@
1191 1193
1192 1194 function store_cache($buffer) {
1193 1195 // Define the cache directory
1194 1196 $cache_directory = bwp_get_cache_dir();
1195 - $url = $this->page_url;
1197 + $url = bwp_canonicalize_page_url($this->page_url);
1196 1198
1197 1199 // Create the cache directory if it doesn't exist
1198 1200 if (!file_exists($cache_directory)) {
1199 1201 mkdir($cache_directory, 0755, true);
@@ -1336,9 +1338,10 @@
1336 1338
1337 1339 $prelaod_html .= '>'.PHP_EOL;
1338 1340 }
1339 1341
1340 - $buffer = berqwp_prependHtmlToHead($buffer, $prelaod_html);
1342 + /* $buffer = berqwp_prependHtmlToHead($buffer, $prelaod_html); */
1343 + $this->early_head_html .= $preload_html;
1341 1344
1342 1345 }
1343 1346
1344 1347
@@ -1515,9 +1518,9 @@
1515 1518 $buffer = $this->lazy_load_videos($buffer);
1516 1519 }
1517 1520
1518 1521 if ($this->settings['youtube_lazyloading']) {
1519 - $buffer = $this->lazy_load_iframes($buffer);
1522 + // $buffer = $this->lazy_load_iframes($buffer);
1520 1523 }
1521 1524
1522 1525 if ($this->settings['css_optimization'] == 'auto') {
1523 1526 if ($this->settings['opt_mode'] == 'basic') {
@@ -1536,21 +1539,28 @@
1536 1539 $this->settings['css_optimization'] = 'delay';
1537 1540 }
1538 1541 }
1539 1542
1540 - $enable_critical_css = (bool) apply_filters('berqwp_local_critical_css', false);
1543 + $enable_used_css = (bool) apply_filters(
1544 + 'berqwp_local_used_css',
1545 + apply_filters('berqwp_local_critical_css', (bool) get_option('berqwp_enable_used_css'))
1546 + );
1541 1547
1542 - if ($enable_critical_css && $this->settings['css_optimization'] !== 'disable') {
1548 + // $enable_used_css = false; // disable
1549 +
1550 + if ($enable_used_css && $this->settings['css_optimization'] !== 'disable') {
1543 1551 $critical_css = new berqUsedCSS(get_option('home'));
1544 1552 $critical_css->forceInclude($this->settings['force_include_critical_css']);
1545 1553 $critical_css = $critical_css->process_css($buffer);
1546 - $critical_css = sprintf('<style data-berqwp-exclude id="berqwp-critical-css">%s</style>', $critical_css);
1554 + $critical_css = sprintf('<style data-berqwp-exclude id="berqwp-used-css">%s</style>', $critical_css);
1547 1555
1548 - $buffer = berqwp_prependHtmlToHead($buffer, $critical_css);
1556 + /* $buffer = berqwp_prependHtmlToHead($buffer, $critical_css); */
1557 + $this->early_head_html .= $critical_css;
1549 1558 $buffer = $this->delay_styles($buffer);
1550 1559
1551 1560 }
1552 1561
1562 + $buffer = berqwp_earlyHeadHtml($buffer, $this->early_head_html);
1553 1563
1554 1564 $buffer = $this->restore_template_scripts( $buffer, $template_placeholders );
1555 1565
1556 1566 $script = apply_filters('berqwp_photon_before_closing_body', $script);