Skip to content
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 #6879 Add meta generator #7034

Merged
merged 17 commits into from
Oct 25, 2024
Merged

Conversation

remyperona
Copy link
Contributor

@remyperona remyperona commented Oct 15, 2024

Description

Fixes #6879

Add meta tag generator to HTML when optimized

Type of change

  • Enhancement (non-breaking change which improves an existing functionality).

Detailed scenario

In optimized HTML, a new meta tag is added:
<meta name="generator" content="WP Rocket" data-wpr-features="" />

The data-wpr-features contains the list of features enabled.

Using rocket_disable_meta_generator filter set to true prevents the meta tag from being added.

Using rocket_display_meta_generator_content set to false removes the content="WP Rocket" part.

Technical description

Documentation

Explain how this code works. Diagrams & drawings are welcome.

Mandatory Checklist

Code validation

  • I validated all the Acceptance Criteria. If possible, provide screenshots or videos.
  • I triggered all changed lines of code at least once without new errors/warnings/notices.
  • I implemented built-in tests to cover the new/changed code.

Code style

  • I wrote a self-explanatory code about what it does.
  • I protected entry points against unexpected inputs.
  • I did not introduce unnecessary complexity.

@remyperona remyperona added this to the 3.17.2 milestone Oct 15, 2024
@remyperona remyperona self-assigned this Oct 15, 2024
Copy link

codacy-production bot commented Oct 17, 2024

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for 3c774bb1 76.24% (target: 50.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (3c774bb) Report Missing Report Missing Report Missing
Head commit (a923ddd) 37818 16660 44.05%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#7034) 101 77 76.24%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

@remyperona remyperona added the type: enhancement Improvements that slightly enhance existing functionality and are fast to implement label Oct 17, 2024
@remyperona remyperona requested a review from a team October 17, 2024 19:46
@remyperona remyperona marked this pull request as ready for review October 17, 2024 19:46
inc/Engine/Support/Data.php Show resolved Hide resolved
inc/Engine/Support/Meta.php Outdated Show resolved Hide resolved
inc/Engine/Support/Meta.php Outdated Show resolved Hide resolved
inc/Engine/Support/Meta.php Show resolved Hide resolved
@jeawhanlee
Copy link
Contributor

Also I noticed that manual_preload was not added to the meta or not?

@remyperona
Copy link
Contributor Author

the preload value is not on the list of things we need to log in the meta

@Mai-Saad
Copy link
Contributor

Mai-Saad commented Oct 21, 2024

@Tabrisrp Thanks for the PR. Please find the exploratory test notes below:

@piotrbak
Copy link
Contributor

piotrbak commented Oct 21, 2024

Updated the Acceptance Criteria based on @Mai-Saad findings:

  1. wpr_cached will be part of the future enhancement
  2. wpr_cached_desktop and wpr_cached_mobile should become wpr_desktop and wpr_mobile. They should be added even if the page is optimised (even if not cached). Notion
  3. When CDN is enabled + nothing added to the DNS Prefetch section, we should not add the wpr_dns_prefetch
  4. When CDN is enabled + something is added to the DNS Prefetch section, we should add the wpr_dns_prefetch
  5. Meta tag should not be added when serving the User Cache
  6. For the asynchronous features, there's additional request here. The meta tag should be added when applying the optimization.

Bugfixes:

  1. Preload fonts not working based on this comment

@remyperona I included everything in this comment, Mai's findings above.
CC @Mai-Saad

@remyperona
Copy link
Contributor Author

When CDN is enabled, the CDN URL is automatically added to the DNS prefetch values using the filter, so that's expected that wpr_dns_prefetch is added in that case.

@piotrbak
Copy link
Contributor

@remyperona Couldn't we do a check there, for example:

  1. If CDN is enabled
  2. There's only one value in DNS Prefetch
  3. Don't add the meta tag

@remyperona
Copy link
Contributor Author

We can, I was explaining why it was happening that way.

Preload fonts are not added in meta now, can you please check? sample page https://new.rocketlabsqa.ovh/combine-v1-v2-fonts/

I can't see any preloaded font on this link. When testing locally with a font added in the preload fonts field, it works correctly. What is the configuration tested on that page?

Copy link

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for 3c774bb1 77.57% (target: 50.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (3c774bb) Report Missing Report Missing Report Missing
Head commit (83cff8f) 37826 16667 44.06%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#7034) 107 83 77.57%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

@remyperona
Copy link
Contributor Author

PR is updated, all points taken care of, waiting for feedback related to the preload fonts.

@Mai-Saad
Copy link
Contributor

Working as expected, failed test have separate GH (already on trunk)
testrail-report-651.pdf

@remyperona remyperona added this pull request to the merge queue Oct 25, 2024
Merged via the queue into develop with commit a1bdab0 Oct 25, 2024
12 of 13 checks passed
@remyperona remyperona deleted the enhancement/6879-meta-generator branch October 25, 2024 15:31
Khadreal pushed a commit that referenced this pull request Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Improvements that slightly enhance existing functionality and are fast to implement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use meta generator to display options enabled
4 participants