Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01269AjGvnGyzCa3USYaTjbU
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01269AjGvnGyzCa3USYaTjbU
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All Submissions:
Changes proposed in this Pull Request:
Above-header Campaign Prompts were appearing only after a multi-second delay on sites running Perfmatters, because the Newspack Perfmatters defaults delay the prompt's view script until the reader's first interaction. The script reveals the prompt (it strips the server-rendered
hiddenclass), so until it runs the prompt is invisible — hurting both visibility and CLS. Reported by CT Mirror and Outlier Media (NPPM-2934).This PR:
newspack-popups,window.newspack,newspack-plugin) from the JS delay queue and addsnewspack-popups/newspack-pluginto the defer exclusions. Every other Newspack script stays delayed, so the rest of the site keeps the performance benefit. Detection isNewspack_Popups_Model::has_published_above_header_prompts()— transient-cached (the filter runs on essentially every front-end request) and invalidated when a prompt is saved, transitions status, has itsplacementmeta changed, or is deleted.The reveal-script set is intentionally minimal (only what gates the prompt becoming visible) rather than un-delaying all Newspack JS. Detection deliberately keys on published + above_header placement only, not full display eligibility (active campaign group / activation window / segment match) — replicating the Inserter's per-request logic on this hot path is too expensive, and the tradeoff is fail-safe: a published-but-never-shown prompt only forfeits the JS-delay optimization, it breaks nothing. This is documented at the detection method.
Closes NPPM-2934.
How to test the changes in this Pull Request:
newspack-popups/window.newspackare no longer in Perfmatters' "Delay JavaScript" list and thatnewspack-popups/newspack-pluginare in the "Exclude from Delay/defer" set (or inspect viaapply_filters( 'option_perfmatters_options', [] )).Other information:
AboveHeaderDetectionTestin newspack-popups;Newspack_Test_Perfmattersin newspack-plugin.)