Closes #49: otf and eot fonts shouldn't be processed by default with preload fonts #50
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.
Description
Fixes #49
The list of font extensions processed will now be dynamically coming from WP Rocket filter rather than a static value.
Type of change
Detailed scenario
What was tested
The value is coming from the variable in the page. If we can't get it, then we have default values.
How to test
Please run with wp-media/wp-rocket#7318 to have the actual variable being added to the html
Technical description
Documentation
This pull request updates the
BeaconPreloadFontsclass to allow configurable font file extensions and improves the flexibility of font file detection. The most important changes include replacing the staticFONT_FILE_REGEXwith an instance-specific regex based on the configuration and updating font-loading logic to use the new regex.Updates to font file detection:
src/BeaconPreloadFonts.js: Replaced the staticFONT_FILE_REGEXwith an instance-specific regex (this.FONT_FILE_REGEX) that is dynamically generated based on theprocessed_extensionsconfiguration. If no configuration is provided, it defaults to["woff", "woff2", "ttf"]. This change ensures greater flexibility in specifying font file extensions.src/BeaconPreloadFonts.js: Updated thegetNetworkLoadedFontsmethod to use the instance-specificthis.FONT_FILE_REGEXinstead of the removed staticFONT_FILE_REGEX. This aligns the method with the new customizable regex logic.New dependencies
None
Risks
None
Mandatory Checklist
Code validation
Code style
Unticked items justification
No test for that