Add Mermaid diagrams and real-world examples for script loading validation#56
Conversation
…ation - Add comprehensive Mermaid diagrams to Prefetch-Resource-Validation: * Visual comparison of preload vs prefetch lifecycle * Decision tree for choosing resource hints * Page load timeline showing prefetch impact * Adaptive prefetch strategy based on connection * Resource lifecycle state diagram - Document real-world consent script scenario in Validate-Preload-Async-Defer-Scripts: * Explain why fetchpriority="high" doesn't solve the problem * Show diagrams comparing different approaches * Provide decision tree for consent script loading * Add priority comparison table * Reference future blog post on server-side conditional loading - Replace complex diagram with clear scenario table for better readability - Add LinkedIn discussion context about third-party consent scripts Visual improvements make it easier to understand: - When to use preload vs prefetch - How resource hints affect page load performance - Optimal strategies for different connection types - Real-world tradeoffs for consent management scripts
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR Review: Add Mermaid diagrams and real-world examplesGreat additions overall! The Mermaid diagrams significantly improve comprehension, and the real-world consent script case study is highly practical. Here are my observations: New File:
|
The summary was counting all resources (issues + validPrefetch) as 'loaded', but resources with 'not-loaded' warnings were incorrectly included. Now correctly filters and counts only resources where loaded: true. Before: counted resources that failed or haven't loaded yet After: accurate count of actually loaded prefetch resources
PR Review: Add Mermaid diagrams and real-world examples for script loading validationOverall this is a high-quality, well-structured contribution that adds significant educational value to the documentation. The new Prefetch Resource Validation (new file)Strengths
Issues / Suggestions
Validate-Preload-Async-Defer-Scripts (updated file)Strengths
Issues / Suggestions
Navigation (_meta.json)The new entry looks correct and consistent with the existing format. Summary
The broken placeholder link (#1 in the second section) is the only change I'd consider blocking. The rest are suggestions for improvement. |
Prefetch-Resource-Validation fixes: - Add 'Duration' column to all output tables to show download times - Improve cache detection: check encodedBodySize > 0 && transferSize === 0 to avoid false positives for cross-origin resources without Timing-Allow-Origin - Add warning for missing 'as' attribute (prevents MIME type matching) - Add comment explaining 5-second heuristic for current-page detection - Add comment clarifying early return is safe (no console.group opened yet) - Add comment explaining shortUrl fallback for bare origin URLs - Update documentation to include new 'missing-as' issue category - Update Resource Analysis table to document Duration column Validate-Preload-Async-Defer-Scripts fixes: - Replace broken placeholder link (#) with plain text for upcoming blog post - Add note that fetchpriority="high" behavior applies to parser-discovered scripts - Add note explaining late-body async script decision tree branch These changes address all feedback from code review: #56 (comment)
PR Review: Add Mermaid diagrams and real-world examplesOverall this is a high-quality, well-structured addition to the documentation. The content is technically accurate and the educational value is strong. Here are my observations: New File:
|
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)
PR Review: Add Mermaid diagrams and real-world examplesOverall this is a solid educational contribution. The new New File:
|
| Area | Assessment |
|---|---|
| Code correctness | ✅ Solid — no bugs found, minor edge cases noted |
| Documentation quality | ✅ High — diagrams and tables improve comprehension |
| Mermaid diagrams | ✅ Clear and accurate |
| Style / conventions | ✅ Follows existing project patterns |
| Minor issues | See notes above — none are blocking |
This PR is ready to merge. The items above are optional improvements rather than blockers.
Prefetch-Resource-Validation fixes: 1. Fix shortUrl hash handling: - Now removes both query params and hash fragments - Prevents URLs like "page#section" from showing hash in console output - Comment documents this behavior 2. Remove "media" from inappropriateness check: - Changed from `as === "video" || as === "media"` to `as === "video" || as === "audio"` - "media" is not a valid HTML spec value for 'as' attribute - Added comment in validAsValues explaining this - More consistent: invalid "as" values get flagged by validator first 3. Document 5-second heuristic limitation: - Added note in Issue Categories table explaining false positives on slow pages - Makes users aware of limitation when evaluating "wrong hint type" errors - Complements existing code comment 4. Improve issue count clarity: - Separate "meaningful issues" (errors/warnings) from info-level (not loaded) - Summary now says: "Issues found: X (excluding 'not loaded' info)" - Prevents misleading count where most "issues" are just "pending" resources - Uses totalMeaningfulIssues in both summary and final message 5. Clarify fetch() example is standalone: - Added note before cache header verification example - Makes clear it's NOT part of the diagnostic snippet - Warns it makes a real network request - Prevents confusion about running standalone code These changes address all suggestions from latest review round: - shortUrl edge case with hashes - as="media" spec inconsistency - 5s heuristic documentation - Issue count clarity - fetch() example clarification
CVE-2026-0969: Vulnerable version of next-mdx-remote (4.4.1) detected. Solution: - Added npm overrides to force next-mdx-remote@^6.0.0 - This overrides the transitive dependency from nextra@2.13.4 - Build tested and working correctly The override ensures Vercel deployment won't be blocked by the security check. Learn more: https://vercel.link/CVE-2026-0969
PR Review: Add Mermaid Diagrams and Real-World ExamplesSummaryThis PR adds two main things:
The content is well-researched and genuinely useful. Below are observations across both content quality and technical concerns. Strengths
Issues to Address1. Mermaid diagrams — not supported by Nextra without a pluginThe MDX files contain 7 Mermaid diagrams (triple-backtick mermaid code blocks). Nextra's default The
This is a blocking concern — the diagrams are central to the new content's value. 2.
|
Prefetch-Resource-Validation fixes: - Add 'Duration' column to all output tables to show download times - Improve cache detection: check encodedBodySize > 0 && transferSize === 0 to avoid false positives for cross-origin resources without Timing-Allow-Origin - Add warning for missing 'as' attribute (prevents MIME type matching) - Add comment explaining 5-second heuristic for current-page detection - Add comment clarifying early return is safe (no console.group opened yet) - Add comment explaining shortUrl fallback for bare origin URLs - Update documentation to include new 'missing-as' issue category - Update Resource Analysis table to document Duration column Validate-Preload-Async-Defer-Scripts fixes: - Replace broken placeholder link (#) with plain text for upcoming blog post - Add note that fetchpriority="high" behavior applies to parser-discovered scripts - Add note explaining late-body async script decision tree branch These changes address all feedback from code review: #56 (comment)
…tion Add Mermaid diagrams and real-world examples for script loading validation
Add comprehensive Mermaid diagrams to Prefetch-Resource-Validation:
Document real-world consent script scenario in Validate-Preload-Async-Defer-Scripts:
Replace complex diagram with clear scenario table for better readability
Add LinkedIn discussion context about third-party consent scripts
Visual improvements make it easier to understand: