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 #7243: Preload fonts frontend #7312

Open
wants to merge 39 commits into
base: feature/preload-fonts
Choose a base branch
from

Conversation

Miraeld
Copy link
Contributor

@Miraeld Miraeld commented Feb 19, 2025

Description

Fixes #7243

This PR brings the front-end optimization to the newly added feature Preload Fonts.

Type of change

  • New feature (non-breaking change which adds functionality).

Detailed scenario

None

Technical description

Documentation

This pull request introduces several changes to the inc/Engine/Media/PreloadFonts/Frontend/Controller.php file to implement font preloading functionality. Additionally, it includes updates to the test fixtures to ensure the feature works correctly.

Key changes:

Implementation of Font Preloading:

  • Added UrlTrait to the Controller class to leverage URL-related utilities.
  • Updated the optimize method to include logic for preloading fonts if the corresponding database row indicates fonts to preload.
  • Introduced the preload_fonts, is_third_party_font, and preload_tag private methods to handle the generation of preload tags for fonts and determine if a font URL is third-party.

Test Fixtures Updates:

Configuration Updates:

  • Updated phpstan-baseline.neon to account for a new usage of apply_filters in the Controller.php file.

New dependencies

None

Risks

None

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.
  • Output messages (errors, notices, logs) are explicit enough for users to understand the issue and are actionnable.

@Miraeld Miraeld self-assigned this Feb 19, 2025
@Miraeld Miraeld changed the title Closes #7243: Preload fonts frontend DRAFT: Closes #7243: Preload fonts frontend Feb 19, 2025
@Miraeld Miraeld linked an issue Feb 19, 2025 that may be closed by this pull request
Copy link

codacy-production bot commented Feb 19, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
-43.96% (target: -0.10%) (target: 50.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (eeaa286) 39257 17258 43.96%
Head commit (33d0397) 0 (-39257) 0 (-17258) 0.00% (-43.96%)

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 (#7312) 0 0 ∅ (not applicable)

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

Base automatically changed from enhancement/7240-beacon-insertion to feature/7242-preload-fonts-data-insertion February 19, 2025 17:42
Base automatically changed from feature/7242-preload-fonts-data-insertion to feature/preload-fonts February 19, 2025 17:54
@Miraeld Miraeld changed the title DRAFT: Closes #7243: Preload fonts frontend Closes #7243: Preload fonts frontend Feb 20, 2025
@Miraeld Miraeld requested a review from a team February 20, 2025 01:27
Copy link
Contributor

@wordpressfan wordpressfan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR depends on the following PR:
#7304

I'm going to document this now to mention how to use the new approach, this will help a lot in preparing the head items not to print the tags directly and will adjust the ordering of preload, preconnect, ...etc. into head.

@wordpressfan
Copy link
Contributor

The new way of printing head elements is documented here:
https://www.notion.so/wpmedia/New-rocket-head-structure-1a0ed22a22f080babda5dc0eff7ea21e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3.19 - Preload Fonts - Frontend optimization part
4 participants