Changeset 3798397 for xspeed/trunk/includes/modules/Minify/MinifyModule.php
- Timestamp:
- 11/12/2026 01:25:30 PM (less than one hour ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
xspeed/trunk/includes/modules/Minify/MinifyModule.php
r3754746 r3798397 93 93 'default' => false, 94 94 'label' => __( 'Load CSS without blocking', 'xspeed' ), 95 'description' => __( 'On pages that have critical CSS, the page shows before the rest of its CSS finishes loading. Pages without critical CSS keep loading their CSS normally, because deferring it makes the page show unstyled and then jump. ', 'xspeed' ),95 'description' => __( 'On pages that have critical CSS, the page shows before the rest of its CSS finishes loading. Pages without critical CSS keep loading their CSS normally, because deferring it makes the page show unstyled and then jump. Pages with a slider, carousel or masonry grid also load their CSS normally, because those scripts lay the page out before late CSS would arrive.', 'xspeed' ), 96 96 ), 97 97 'remove_query_strings' => array( … … 153 153 'default' => false, 154 154 'label' => __( 'Combine CSS files', 'xspeed' ), 155 'description' => __( 'Joins your site\'s own CSS files into one. This helps only on old HTTP/1.1 servers, so leave it off on most hosts. ', 'xspeed' ),155 'description' => __( 'Joins your site\'s own CSS files into one. This helps only on old HTTP/1.1 servers, so leave it off on most hosts. Runs for logged-in visitors too, so an admin browsing the site sees the combined page.', 'xspeed' ), 156 156 'advanced' => true, 157 157 ), … … 160 160 'default' => false, 161 161 'label' => __( 'Combine JavaScript files', 'xspeed' ), 162 'description' => __( 'Joins your site\'s own scripts into one file. Turn off if a script stops working after you enable it. ', 'xspeed' ),162 'description' => __( 'Joins your site\'s own scripts into one file. Turn off if a script stops working after you enable it. Runs for logged-in visitors too, so an admin browsing the site sees the combined page.', 'xspeed' ), 163 163 'advanced' => true, 164 164 ), … … 258 258 */ 259 259 add_action( 'init', array( $this, 'boot_on_init' ) ); 260 // A saved change can lift the reason a page was left alone, so the 261 // panel starts its list again from the next cache MISS. (#553) 262 add_action( 263 'update_option_' . Settings_Manager::OPTION_PREFIX . self::SLUG, 264 static function (): void { 265 delete_transient( Minify_Filters::ASYNC_CSS_SKIPS_TRANSIENT ); 266 } 267 ); 260 268 } 261 269 … … 286 294 */ 287 295 public function ui_notices(): array { 288 $opts = $this->get_settings(); 296 $opts = $this->get_settings(); 297 $notices = $this->async_css_notices( $opts ); 289 298 if ( empty( $opts['minify_html'] ) ) { 290 return array();299 return $notices; 291 300 } 292 301 293 302 $reason = LegacyMinifier::skip_reason(); 294 303 if ( '' === $reason ) { 295 return array();304 return $notices; 296 305 } 297 306 … … 302 311 : __( 'HTML minification is paused because a plugin or theme is returning true from the xspeed_skip_minify filter. Cached pages are served un-minified until that filter stops suppressing it.', 'xspeed' ); 303 312 304 return array( 305 array( 313 $notices[] = array( 314 'tone' => 'info', 315 'title' => __( 'HTML minification is on but currently paused', 'xspeed' ), 316 'body' => $body, 317 ); 318 return $notices; 319 } 320 321 /** 322 * Say which pages Load CSS without blocking left alone, and why. 323 * 324 * Both guards in Minify_Filters::async_style_tag() are deliberate, but 325 * the setting read "on" while a slider page's stylesheets stayed 326 * render-blocking, with nothing saying why. (#553) 327 * 328 * @param array<string,mixed> $opts This module's settings. 329 * @return array<int,array<string,mixed>> 330 */ 331 private function async_css_notices( array $opts ): array { 332 if ( empty( $opts['async_css'] ) ) { 333 return array(); 334 } 335 $report = get_transient( Minify_Filters::ASYNC_CSS_SKIPS_TRANSIENT ); 336 if ( ! is_array( $report ) ) { 337 return array(); 338 } 339 340 $notices = array(); 341 foreach ( array( 'no_critical_css', 'js_measured_layout' ) as $reason ) { 342 if ( empty( $report[ $reason ]['paths'] ) || ! is_array( $report[ $reason ]['paths'] ) ) { 343 continue; 344 } 345 $paths = implode( ', ', array_map( 'strval', $report[ $reason ]['paths'] ) ); 346 $handles = isset( $report[ $reason ]['handles'] ) && is_array( $report[ $reason ]['handles'] ) 347 ? implode( ', ', array_map( 'strval', $report[ $reason ]['handles'] ) ) 348 : ''; 349 350 if ( 'no_critical_css' === $reason ) { 351 $body = sprintf( 352 /* translators: %s: comma-separated page paths, e.g. "/, /shop/". */ 353 __( 'Stylesheets stayed render-blocking on %s because those pages have no critical CSS. Without it, deferred CSS makes the page show unstyled and then jump. A theme or plugin that inlines critical CSS for a page can return true from the xspeed_async_css_page_has_critical_css filter.', 'xspeed' ), 354 $paths 355 ); 356 } elseif ( '' !== $handles ) { 357 $body = sprintf( 358 /* translators: 1: comma-separated page paths, 2: comma-separated script handles, e.g. "swiper". */ 359 __( 'Stylesheets stayed render-blocking on %1$s because a script there lays the page out by measuring it (%2$s). Sliders, carousels and masonry grids stay broken when their CSS arrives after the script has run. If the layout on those pages is pure CSS, return false from the xspeed_async_css_js_measured_layout filter.', 'xspeed' ), 360 $paths, 361 $handles 362 ); 363 } else { 364 $body = sprintf( 365 /* translators: %s: comma-separated page paths, e.g. "/, /shop/". */ 366 __( 'Stylesheets stayed render-blocking on %s because the xspeed_async_css_js_measured_layout filter reports a layout built by a script there. Return false from that filter if the layout on those pages is pure CSS.', 'xspeed' ), 367 $paths 368 ); 369 } 370 371 $notices[] = array( 306 372 'tone' => 'info', 307 'title' => __( 'HTML minification is on but currently paused', 'xspeed' ), 373 'title' => 'no_critical_css' === $reason 374 ? __( 'Load CSS without blocking skipped pages without critical CSS', 'xspeed' ) 375 : __( 'Load CSS without blocking skipped pages with a slider or grid', 'xspeed' ), 308 376 'body' => $body, 309 ), 310 ); 377 ); 378 } 379 return $notices; 311 380 } 312 381
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)