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 preferences |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR enhances font preloading by excluding non-stylable elements before running visibility and position checks.
- Introduces an
EXCLUDED_TAG_NAMESset plus two methods—canElementBeStyledWithFontFamilyandcanElementBeProcessed—to filter out elements that can’t usefont-family. - Updates the
run()andprocessExternalFonts()methods to use the new combined filtering logic. - Adds unit tests for both new methods.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/BeaconPreloadFonts.test.js | Added tests for canElementBeStyledWithFontFamily and canElementBeProcessed |
| src/BeaconPreloadFonts.js | Declared EXCLUDED_TAG_NAMES, implemented two filtering methods, and updated element filters in run and processExternalFonts |
Comments suppressed due to low confidence (2)
test/BeaconPreloadFonts.test.js:222
- The tests cover only a subset of excluded tags; consider parameterizing or looping through the full
EXCLUDED_TAG_NAMESlist to ensure complete coverage.
describe('canElementBeStyledWithFontFamily', () => {
src/BeaconPreloadFonts.js:92
- [nitpick] The method name is lengthy; you might rename it to something like
isElementFontStylableorisFontFamilyApplicablefor brevity and clarity.
canElementBeStyledWithFontFamily(element) {
8 tasks
jeawhanlee
approved these changes
Jul 8, 2025
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.
Description
Fixes #7428
This enhancement improves font preloading performance by filtering out HTML elements that cannot be styled with font-family CSS properties before processing them for visibility and position checks.
Type of change
Detailed scenario
What was tested
Automated Testing:
canElementBeStyledWithFontFamily()andcanElementBeProcessed()methodsManual Testing Scenarios:
<img>,<script>,<meta>,<br>are excluded from font analysis<p>,<div>,<span>continue to be processed normallyHow to test
Describe how the PR can be tested so that the validator can be autonomous: environment, dependencies, specific setup, steps to perform, API requests, etc.
Technical description
Documentation
Implementation Details:
canElementBeStyledWithFontFamily(element): Checks if element's tagName is not in excluded setcanElementBeProcessed(element): Combines font-family check with above-fold visibility checkrun()method: Changed from.filter(el => this.isElementAboveFold(el))to.filter(el => this.canElementBeProcessed(el))processExternalFonts()method: Applied same filtering improvementFlow Diagram
New dependencies
None
Risks
None
Mandatory Checklist
Code validation
Code style