Set a JS bundle SEO budget: splitting, critical path, and render delays guardrails.
- User
Set a JS bundle SEO budget: splitting, critical path, and render delays guardrails.
Assistant
Set a JS bundle SEO budget: splitting, critical path, and render delays guardrails.
1. Analyze the User's Request: * Topic: Setting a JavaScript (JS) bundle SEO budget. * Specifics: Needs to cover "splitting," "critical path," and "render delays" guardrails. * Goal: Define concrete metrics or rules (a "budget") to ensure SEO performance isn't hurt by heavy JS usage.
Deconstruct the Components:
Formulate the Strategy/Guardrails:
<head> unless absolutely necessary (e.g., anti-flicker snippets, but even those have timeouts).Drafting the "Budget" Structure (Iterative refinement):
Phase 1: The Total Volume Budget (The "Weight" Limit)
Phase 2: The Critical Path Budget (The "Blocking" Limit)
Phase 3: Splitting & Lazy Loading (The "Architecture" Limit)
Phase 4: Rendering (The "Googlebot" Limit)
Structuring the Output: I should present this as a formal "Budget Proposal" or "Guardrail Document" with specific numbers. I will organize it by the user's requested categories: Splitting, Critical Path, and Render Delays.
Refining the Numbers (The "Expert" Touch):
Writing the Content (Mental Draft & Polish):
Final Review against User Prompt:
Formatting: Use tables and bullet points for readability. (Self-correction: Make sure to distinguish between Compressed and Uncompressed sizes, as SEOs often confuse them. Parse time depends on uncompressed).
(Self-Correction during drafting): I initially thought about suggesting specific tools, but the user asked for guardrails, not a tool list. I will include a section on "Enforcement" which implies tools like Lighthouse/WebPageTest, but the focus remains on the rules.
Here is a tiered guardrail system for JS performance, structured by the three constraints you identified.
Goal: Reduce the payload of the initial request so the browser can reach "Processing" faster.
| Metric | Guardrail | Reasoning |
|---|---|---|
| Critical Bundle Size | < 100 KB (Gzipped) | The main "app" bundle (React/Vue/Angular core + critical components) must download almost instantly on 4G/Mobile. |
| Route Chunk Size | < 50 KB (Gzipped) | Code specific to a single page/view should be lazy-loaded. If a route exceeds this, split it further. |
| Third-Party Script Budget | Max 2 Scripts / < 100 KB | 3rd party scripts (analytics, chat widgets) are SEO killers. Facade them or lazy-load them after user interaction. |
| Total JS Budget | < 300–500 KB | This is the hard limit for the entire page weight in JS (compressed). Anything higher triggers "Avoid an excessive DOM size" and parse-time warnings. |
Enforcement:
performance.maxEntrypointSize and maxAssetSize in your build config to fail the build if limits are breached.Goal: Minimize "Long Tasks" that block the Main Thread. Google measures this heavily via INP (Interaction to Next Paint) and TBT (Total Blocking Time).
| Metric | Guardrail | Reasoning |
|---|---|---|
| Main Thread Occupancy | < 300ms | The total time spent parsing JS, calculating styles, and laying out the page must stay under 300ms combined. |
| Long Tasks | 0 Tasks > 50ms | A "Long Task" is any JS execution that blocks the main thread for >50ms. These ruin INP and delay hydration. Aim for zero. |
| Script Assessment | defer or async mandatory | No blocking <script> tags in the <head> unless absolutely necessary for initial render. |
| Hydration Cost | < 200ms | (For frameworks like React/Vue) The time it takes to "wake up" the page and attach event listeners must be imperceptible. |
Enforcement:
Goal: Ensure content appears in the viewport (LCP) and is interactive (TTI) before the crawler times out.
| Metric | Guardrail | Reasoning |
|---|---|---|
| LCP (Largest Contentful Paint) | < 2.5s | The primary image or text block must render within 2.5s. If JS fetches this data client-side, you will likely fail this budget. |
| TTI (Time to Interactive) | < 3.8s | The page must be clickable and responsive before 3.8s. Heavy JS often creates a "ghost" page (looks done, but links don't work). |
| Data Fetching Delay | 0ms (Server-Side) | Strict Guardrail: Do not rely on client-side fetch() or useEffect for primary SEO content. Data must exist in the HTML (SSR/SSG) or be baked into the bundle. |
| Googlebot Timeout | Implicit 5–10s | While Googlebot is patient, other search engines and mobile crawlers are not. All critical content must be visible in the DOM snapshot within ~5 seconds of fetch completion. |
Enforcement:
client:load hydration for core content, it fails the SEO budget.If you are setting this up in a performance-budget.json file or a CI/CD pipeline, use these thresholds:
{
"budgets": [
{
"resourceType": "script",
"budgetType": "size",
"bytes": 300000
},
{
"resourceType": "script",
"budgetType": "count",
"count": 5
},
{
"metric": "total-blocking-time",
"budgetType": "ms",
"milliseconds": 200
},
{
"metric": "largest-contentful-paint",
"budgetType": "ms",
"milliseconds": 2500
}
]
}
Even if you hit the performance budgets above, you have an SEO budget failure if:
<h1>, meta description, or internal links.