-
Notifications
You must be signed in to change notification settings - Fork 227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closes #7066: 3.18 - Preconnect and prefetch removal #7101
Closes #7066: 3.18 - Preconnect and prefetch removal #7101
Conversation
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferencesCodacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more Footnotes
|
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferencesCodacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more Footnotes
|
I tested that this works as expected. |
Description
#7091 needs to be merged first. This PR is based on the current build of this PR. Only the last two commits are for this PR.
Fixes #7066
We are removing the
prefetch
andpreconnect
tag from the html if we are serving local hosted google fonts.Type of change
Detailed scenario
Media
tab of WPR settingsTechnical description
Documentation
This enhancement introduces a method to remove preconnect and prefetch links for Google Fonts from the HTML content. The purpose of this change is to optimize the loading process by eliminating unnecessary DNS prefetch and preconnect requests for Google Fonts.
How It Works
Method Introduction: A new private method remove_preconnect_and_prefetch is added to the Controller class.
HTML Content Check: The method first checks if the provided HTML content is empty. If it is, the original HTML is returned.
Filter Application: A filter
rocket_remove_font_pre_links
is applied to determine whether the preconnect and prefetch links should be removed. If the filter returns false, the original HTML is returned.Pattern Matching: A regular expression pattern is used to match
preconnect
andprefetch
links for Google Fonts.Tags Removal: The matched tags are removed from the HTML content using
preg_replace
.Return Modified HTML: The modified HTML content, without the
preconnect
andprefetch
links, is returned.New dependencies
None
Risks
None
Mandatory Checklist
Code validation
Code style