← All Exercises
Sum the Blocking Critical Path Against a Budget
basicjavascript
Background
LCP is dominated by the blocking path, not total page weight. Budgeting the path specifically targets what delays first paint.
Problem
Sum the transfer size of render-blocking resources on a page path and report whether the path exceeds its budget, listing the largest contributor.
Input
JSON object: { resources: [{ url, sizeKb, blocking }], budgetKb }Output
JSON object: { criticalKb, overBudget, largest }Sample tests
Sample 1
Input: {"resources":[{"url":"/app.css","sizeKb":40,"blocking":true},{"url":"/font.woff2","sizeKb":30,"blocking":false},{"url":"/app.js","sizeKb":120,"blocking":true}],"budgetKb":150}Expected: {"criticalKb":160,"overBudget":true,"largest":"/app.js"}Sample 2
Input: {"resources":[{"url":"/app.css","sizeKb":40,"blocking":true}],"budgetKb":150}Expected: {"criticalKb":40,"overBudget":false,"largest":"/app.css"}Your solution
Learning objective
Budget the render-blocking path rather than total page weight.