Skip to content

add layout shift script#8

Merged
nucliweb merged 4 commits into
mainfrom
layout-shifts
Nov 15, 2022
Merged

add layout shift script#8
nucliweb merged 4 commits into
mainfrom
layout-shifts

Conversation

@jhadev

@jhadev jhadev commented Sep 6, 2022

Copy link
Copy Markdown
Contributor

Was experimenting with this but might refine it more.

@nucliweb nucliweb left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Awesome @jhadev 😊

Thank you

@nucliweb nucliweb merged commit 45614c6 into main Nov 15, 2022
@nucliweb nucliweb deleted the layout-shifts branch November 15, 2022 08:55
nucliweb added a commit that referenced this pull request Feb 12, 2026
Validate-Preload-Async-Defer-Scripts:
- Add missing fetchpriority="low" to <link rel=preload> tag in Solution 1
  This was a correctness bug - preload without fetchpriority="low" still
  escalates network priority even if script tag has fetchpriority="low"

Prefetch-Resource-Validation (comprehensive improvements):

Performance optimizations:
- Pre-normalize all URLs once into a Map (eliminates O(N×M) URL parsing)
- Use pre-built URL map for all matching operations
- Remove redundant URL parsing in nested loops
- Performance improvement: ~6000 URL objects → ~200 for typical cases

New validations:
- Detect invalid 'as' attribute values (typos like as="scriptt")
- Detect duplicate prefetch hints (same URL prefetched multiple times)
- Warn about large scripts (>1MB threshold, was missing)
- Validate 'as' attribute against list of valid values

Improved logic:
- Better cache detection: distinguish "cached" vs "unknown (CORS)"
  Handles case where CORS blocks timing info (both sizes === 0)
- Fixed inappropriateTypes to check scripts and provide detailed reasons
- Optimized isCurrentPageResource check to use pre-built map
- Added seenUrls Set to track duplicates

Code quality:
- Added validAsValues Set with all valid 'as' attribute values
- Added THRESHOLDS.largeScriptSize (1MB) for script-specific checks
- Better error messages with specific size/reason for inappropriateness
- Comments explaining CORS edge cases and validation logic

Documentation updates:
- Added "Invalid as", "Duplicate prefetch" to issue categories table
- Updated "Inappropriate type" description to mention scripts
- Cache status can now show "unknown (CORS)" in output

Addresses issues from comprehensive code review:
- URL matching performance (#8, #9 from analysis)
- Invalid 'as' validation (#7)
- Duplicate detection (#14)
- Large script detection (#4)
- Cache detection for CORS (#3)
- Current page detection optimization (#6)
nucliweb added a commit that referenced this pull request Feb 25, 2026
nucliweb added a commit that referenced this pull request Feb 25, 2026
Validate-Preload-Async-Defer-Scripts:
- Add missing fetchpriority="low" to <link rel=preload> tag in Solution 1
  This was a correctness bug - preload without fetchpriority="low" still
  escalates network priority even if script tag has fetchpriority="low"

Prefetch-Resource-Validation (comprehensive improvements):

Performance optimizations:
- Pre-normalize all URLs once into a Map (eliminates O(N×M) URL parsing)
- Use pre-built URL map for all matching operations
- Remove redundant URL parsing in nested loops
- Performance improvement: ~6000 URL objects → ~200 for typical cases

New validations:
- Detect invalid 'as' attribute values (typos like as="scriptt")
- Detect duplicate prefetch hints (same URL prefetched multiple times)
- Warn about large scripts (>1MB threshold, was missing)
- Validate 'as' attribute against list of valid values

Improved logic:
- Better cache detection: distinguish "cached" vs "unknown (CORS)"
  Handles case where CORS blocks timing info (both sizes === 0)
- Fixed inappropriateTypes to check scripts and provide detailed reasons
- Optimized isCurrentPageResource check to use pre-built map
- Added seenUrls Set to track duplicates

Code quality:
- Added validAsValues Set with all valid 'as' attribute values
- Added THRESHOLDS.largeScriptSize (1MB) for script-specific checks
- Better error messages with specific size/reason for inappropriateness
- Comments explaining CORS edge cases and validation logic

Documentation updates:
- Added "Invalid as", "Duplicate prefetch" to issue categories table
- Updated "Inappropriate type" description to mention scripts
- Cache status can now show "unknown (CORS)" in output

Addresses issues from comprehensive code review:
- URL matching performance (#8, #9 from analysis)
- Invalid 'as' validation (#7)
- Duplicate detection (#14)
- Large script detection (#4)
- Cache detection for CORS (#3)
- Current page detection optimization (#6)
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.

2 participants