| @@ -75,8 +75,15 @@ | ||
| 75 | 75 | add_filter( 'style_loader_src', array( __CLASS__, 'rewrite_style' ), 10, 2 ); |
| 76 | 76 | } |
| 77 | 77 | if ( ! empty( $opts['minify_js'] ) ) { |
| 78 | 78 | add_filter( 'script_loader_src', array( __CLASS__, 'rewrite_script' ), 10, 2 ); |
| 79 | + // The src rewrite above runs before any plugin's own | |
| 80 | + // `script_loader_tag` filter can stamp data-no-minify / | |
| 81 | + // data-no-optimize onto the tag, so the marker arrives too late | |
| 82 | + // to prevent it. Priority 15: after third-party tag filters at | |
| 83 | + // the default 10 have printed their markers, before our defer | |
| 84 | + // (20) and delay (30) look at the tag. (#456) | |
| 85 | + add_filter( 'script_loader_tag', array( Minify_Filters::class, 'restore_marked_script_src' ), 15, 3 ); | |
| 79 | 86 | } |
| 80 | 87 | |
| 81 | 88 | // Phase 4.1a — filter-only "smarter minifier" features. Each is |
| 82 | 89 | // gated on its own toggle so users can enable any subset. |
| @@ -432,8 +439,14 @@ | ||
| 432 | 439 | } |
| 433 | 440 | list( , $open, $body, $close ) = $parts; |
| 434 | 441 | |
| 435 | 442 | if ( '' === trim( $body ) ) { |
| 443 | + return $block; | |
| 444 | + } | |
| 445 | + | |
| 446 | + // The tag asked to be left alone (data-no-optimize / data-no-minify — | |
| 447 | + // the convention consent managers print on their config scripts). (#456) | |
| 448 | + if ( Minify_Filters::tag_opts_out( $open ) ) { | |
| 436 | 449 | return $block; |
| 437 | 450 | } |
| 438 | 451 | |
| 439 | 452 | // Refuse a body that is already structurally broken. balanced() only |