Skip to content

Commit 7824832

Browse files
committed
docs: apply webperf-docs-reviewer rules to Find-render-blocking-resources
- Remove ### Overview section, intro paragraph goes directly under title - Replace 9 bold-as-headers with ### headings in sentence case - Fix 4 headings from title case to sentence case - Refactor JS snippet: calculate lastBlockingEnd, totalSizeBytes, byType once before if/else to eliminate duplicate computation
1 parent d694381 commit 7824832

2 files changed

Lines changed: 25 additions & 29 deletions

File tree

pages/Loading/Find-render-blocking-resources.mdx

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,28 @@ import { Snippet } from '../../components/Snippet'
33

44
# Find render-blocking resources
55

6-
### Overview
7-
86
Identifies resources that block the browser from rendering the page. These resources must be fully downloaded and processed before the browser can display any content, directly impacting First Contentful Paint (FCP) and Largest Contentful Paint (LCP).
97

10-
**Why this matters:**
8+
### Why this matters
119

1210
Render-blocking resources are the primary cause of slow initial page renders. Users see a blank white screen while CSS and JavaScript files download and parse. On slow connections or mobile networks, this can add several seconds to your load time. Eliminating or deferring render-blocking resources is one of the highest-impact optimizations you can make.
1311

14-
**What are render-blocking resources?**
12+
### What are render-blocking resources?
1513

1614
| Resource Type | When it blocks rendering |
1715
|---------------|-------------------------|
1816
| **CSS** | All `<link rel="stylesheet">` in `<head>` block rendering by default |
1917
| **JavaScript** | Scripts without `async` or `defer` in `<head>` block parsing and rendering |
2018
| **Fonts** | `@font-face` fonts block text rendering until loaded |
2119

22-
**Impact on performance:**
20+
### Impact on performance
2321

2422
- Delays First Contentful Paint (FCP)
2523
- Can delay Largest Contentful Paint (LCP)
2624
- Users see a blank page while resources load
2725
- Particularly harmful on slow connections
2826

29-
**Render-Blocking Timeline:**
27+
### Render-blocking timeline
3028

3129
```mermaid
3230
sequenceDiagram
@@ -59,15 +57,15 @@ sequenceDiagram
5957
Note over Browser,Render: User sees content
6058
```
6159

62-
> **Browser Support:** The `renderBlockingStatus` property is currently Chromium-only (Chrome 107+, Edge 107+, Opera 93+). Firefox and Safari don't support this API yet.
60+
> **Browser support:** The `renderBlockingStatus` property is currently Chromium-only (Chrome 107+, Edge 107+, Opera 93+). Firefox and Safari don't support this API yet.
6361
6462
### Snippet
6563

6664
<Snippet code={snippet} />
6765

68-
### Understanding the Results
66+
### Understanding the results
6967

70-
**Summary Metrics:**
68+
### Summary metrics
7169

7270
| Metric | Description |
7371
|--------|-------------|
@@ -76,7 +74,7 @@ sequenceDiagram
7674
| **Total size** | Combined transfer size of all blocking resources |
7775
| **By type** | Breakdown by resource type (script, link/css, font) |
7876

79-
**Timeline Visualization:**
77+
### Timeline visualization
8078

8179
Shows each resource with:
8280
- Resource type
@@ -86,7 +84,7 @@ Shows each resource with:
8684

8785
Resources are sorted by completion time (latest first), so you can see which resource is the last to complete and thus determines when rendering can start.
8886

89-
### Optimization Decision Tree
87+
### Optimization decision tree
9088

9189
```mermaid
9290
flowchart TD
@@ -116,9 +114,9 @@ flowchart TD
116114
style Preload fill:#E5FFE5
117115
```
118116

119-
### Common Render-Blocking Patterns
117+
### Common render-blocking patterns
120118

121-
**Scripts in `<head>` without defer/async:**
119+
### Scripts in `<head>` without defer/async
122120

123121
```html
124122
<!-- ❌ Render-blocking -->
@@ -132,7 +130,7 @@ flowchart TD
132130
</head>
133131
```
134132

135-
**External stylesheets:**
133+
### External stylesheets
136134

137135
```html
138136
<!-- ❌ Render-blocking (but often necessary) -->
@@ -143,7 +141,7 @@ flowchart TD
143141
<noscript><link rel="stylesheet" href="non-critical.css"></noscript>
144142
```
145143

146-
**Web fonts:**
144+
### Web fonts
147145

148146
```css
149147
/* ❌ Blocks text rendering */
@@ -160,7 +158,7 @@ flowchart TD
160158
}
161159
```
162160

163-
### Further Reading
161+
### Further reading
164162

165163
- [Eliminate render-blocking resources](https://developer.chrome.com/docs/lighthouse/performance/render-blocking-resources) | Chrome Developers
166164
- [Render-blocking CSS](https://web.dev/articles/critical-rendering-path/render-blocking-css) | web.dev

snippets/Loading/Find-render-blocking-resources.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@
3131
})
3232
.sort((a, b) => b.responseEnd - a.responseEnd);
3333

34+
const lastBlockingEnd = blockingResources.length
35+
? Math.max(...blockingResources.map((r) => r.responseEnd))
36+
: 0;
37+
const totalSizeBytes = blockingResources.reduce((sum, r) => sum + r.size, 0);
38+
const byType = blockingResources.reduce((acc, r) => {
39+
acc[r.type] = (acc[r.type] || 0) + 1;
40+
return acc;
41+
}, {});
42+
3443
console.group("%c🚧 Render-Blocking Resources", "font-weight: bold; font-size: 14px;");
3544

3645
if (blockingResources.length === 0) {
@@ -45,14 +54,6 @@
4554
console.log(" • Scripts use async or defer attributes");
4655
console.log(" • Critical resources are optimized");
4756
} else {
48-
// Calculate metrics
49-
const lastBlockingEnd = Math.max(...blockingResources.map((r) => r.responseEnd));
50-
const totalSize = blockingResources.reduce((sum, r) => sum + r.size, 0);
51-
const byType = blockingResources.reduce((acc, r) => {
52-
acc[r.type] = (acc[r.type] || 0) + 1;
53-
return acc;
54-
}, {});
55-
5657
// Summary
5758
console.log(
5859
`%c⚠️ Found ${blockingResources.length} render-blocking resource(s)`,
@@ -63,8 +64,8 @@
6364
console.log("%c📊 Impact Summary:", "font-weight: bold;");
6465
console.log(` Rendering blocked until: ${lastBlockingEnd.toFixed(0)}ms`);
6566
console.log(` Total blocking resources: ${blockingResources.length}`);
66-
if (totalSize > 0) {
67-
const sizeKB = (totalSize / 1024).toFixed(1);
67+
if (totalSizeBytes > 0) {
68+
const sizeKB = (totalSizeBytes / 1024).toFixed(1);
6869
console.log(` Total size: ${sizeKB} KB`);
6970
}
7071
console.log(` By type: ${Object.entries(byType).map(([k, v]) => `${k} (${v})`).join(", ")}`);
@@ -134,9 +135,6 @@
134135

135136
console.groupEnd();
136137

137-
const lastBlockingEnd = blockingResources.length ? Math.max(...blockingResources.map((r) => r.responseEnd)) : 0;
138-
const totalSizeBytes = blockingResources.reduce((sum, r) => sum + r.size, 0);
139-
const byType = blockingResources.reduce((acc, r) => { acc[r.type] = (acc[r.type] || 0) + 1; return acc; }, {});
140138
return {
141139
script: "Find-render-blocking-resources",
142140
status: "ok",

0 commit comments

Comments
 (0)