| @@ -98,8 +98,14 @@ | ||
| 98 | 98 | // Delay applies a transform that's mutually exclusive with |
| 99 | 99 | // plain defer — when both are on, delay wins (the bootstrap |
| 100 | 100 | // will re-attach as a regular <script> on interaction). |
| 101 | 101 | add_filter( 'script_loader_tag', array( Minify_Filters::class, 'delay_script_tag' ), 30, 3 ); |
| 102 | + // Smart Delay: a delayed handle's before/after snippets park with | |
| 103 | + // it, or the inline consumer would run at parse time against a | |
| 104 | + // global that now arrives on first interaction. This filter fires | |
| 105 | + // for every inline script WordPress prints, so it also covers | |
| 106 | + // pages the cache buffer never filters. | |
| 107 | + add_filter( 'wp_inline_script_attributes', array( Minify_Filters::class, 'park_smart_inline' ), 30, 2 ); | |
| 102 | 108 | add_action( 'wp_footer', array( Minify_Filters::class, 'print_delay_bootstrap' ), 1000 ); |
| 103 | 109 | // script_loader_tag only fires for wp_enqueue_script()'d assets. |
| 104 | 110 | // Analytics / pixel / chat-widget tags printed straight into |
| 105 | 111 | // wp_head bypass it, and those are usually the heaviest scripts |