diff --git a/plugins/newspack-plugin/includes/plugins/class-perfmatters.php b/plugins/newspack-plugin/includes/plugins/class-perfmatters.php index 59da3094c2..d776bf40f2 100644 --- a/plugins/newspack-plugin/includes/plugins/class-perfmatters.php +++ b/plugins/newspack-plugin/includes/plugins/class-perfmatters.php @@ -85,6 +85,46 @@ private static function scripts_to_delay() { return $scripts_to_delay; } + /** + * Scripts on the reveal path of above-header prompts. + * + * These are excluded from JS delay when published above-header prompts exist so the + * prompts show immediately: the Campaigns view script (newspack-popups) removes the + * prompt's `hidden` class, and the reader data library (window.newspack / + * newspack-plugin) drives that reveal when segments are configured. + * + * @return string[] Script identifiers. + */ + private static function above_header_reveal_scripts() { + return [ 'newspack-popups', 'window.newspack', 'newspack-plugin' ]; + } + + /** + * Reveal-path scripts to exclude from JS deferral when above-header prompts exist. + * + * Derived from above_header_reveal_scripts() minus `window.newspack`: that token + * matches an inline script, and Perfmatters' deferral only applies to external + * `