Render-Blocking Các tài nguyên
Điều gì render-blocking các tài nguyên là, cách CSS và synchronous JavaScript delay đó cốt yếu kết xuất path, vì sao đó hurts Core Web Vitals (và indirectly SEO), cách tìm them, và cách sửa them với async, defer, cốt yếu CSS, và media các truy vấn.
Ngôn ngữ
Render-blocking các tài nguyên là CSS và synchronous JavaScript files một trình duyệt phải download và xử lý trước điều này có thể paint bất cứ điều gì. An applicable stylesheet trong đó head là render-blocking theo mặc định; một <script> trong đó head không có async hoặc defer là parser-blocking theo mặc định (một related nhưng formally distinct mechanism từ đó HTML spec rõ ràng blocking="render" thuộc tính). async loads trong parallel và chạy khi ready (unordered); defer loads trong parallel và chạy sau phân tích cú pháp, trong order; module scripts defer theo mặc định. They có thể delay Đầu tiên Contentful Paint và Largest Contentful Paint, và LCP là dùng by Google Core Web Vitals xếp hạng các hệ thống — một tiebreaker, không một được ghi lại dominant xếp hạng factor. All eligible 200-status các trang enter Google kết xuất queue regardless of liệu JavaScript là present; Google fetches nhiều nhất 2 MB theo non-PDF URL (including các header), riêng cho mỗi referenced file, mà là một fetch limit, không một render-blocking-cụ thể hình phạt. Tìm them với đó hiện tại Lighthouse 13 'Render blocking các yêu cầu' Insight và đó Chrome DevTools Coverage tab; cách sửa by deferring non-cốt yếu JS, inlining chỉ cốt yếu CSS nơi một trace cho thấy đây là đó bottleneck, và dùng media các thuộc tính cho conditional stylesheets — thì re-kiểm thử on một repeated trace.
Evidence for this claim Stylesheets participate in the critical rendering path and can block first render until CSS is processed. Scope: Current official or standards documentation. Confidence: high · Verified: web.dev: Critical rendering path Evidence for this claim Classic scripts without async or defer can block HTML parsing while fetched and executed. Scope: Current official or standards documentation. Confidence: high · Verified: MDN: script elementTóm tắt — Render-blocking các tài nguyên là CSS và JavaScript files của bạn trình duyệt có để download và chạy trước khi nó có thể hiển thị bất cứ điều gì on screen. blank white trang trong khi những điều đó files load là symptom. CSS chặn theo mặc định;
<script>trong<head>không cóasynchoặcdefercũng chặn. khắc phục là để load non-essential stuff sau đó so trang có thể paint sooner.
Điều gì “render-blocking” (bản dịch) «render-blocking» có nghĩa là
Khi ai đó opens của bạn trang, trình duyệt đọc HTML từ top để bottom. Along way nó hits files nó cần để draw trang — mostly CSS stylesheets và JavaScript. Some của những điều đó files làm trình duyệt dừng và chờ: nó sẽ không paint single pixel cho đến khi họ’re downloaded và processed. những điều đó là render-blocking các tài nguyên.
Đó là lý làm chậm trang thường hiển thị blank white screen đầu tiên, sau đó mọi thứ xuất hiện tại sau khi. trình duyệt có HTML, nhưng nó là đang chờ on stylesheet hoặc script trước khi nó sẽ draw bất cứ điều gì.
hai kinds
- CSS là render-blocking theo mặc định khi đó trình duyệt discovers một
<link rel="stylesheet">trong đó<head>trong khi phân tích cú pháp và đó stylesheet thực ra áp dụng (không non-matchingmedia, khôngdisabled). Đó trình duyệt không muốn để cho thấy bạn unstyled nội dung và thì re-style điều này (đó flash looks hỏng), so điều này chờ cho applicable CSS trước việc vẽ. - JavaScript pauses HTML phân tích cú pháp khi đây là một đơn giản
<script>trong đó<head>không cóasynchoặcdefer— đó trình duyệt có để dừng reading đó HTML, go fetch đó script, chạy điều này, và chỉ thì continue. (Technically này là “parser-blocking” (bản dịch) «parser-blocking»; liệu điều này cũng formally được tính as “render-blocking” (bản dịch) «render-blocking» phụ thuộc vào trình duyệt internals hầu hết readers không cần — see Advanced.)
Vì sao điều này quan trọng
lâu hơn trình duyệt chờ, lâu hơn của bạn khách truy cập stares tại không có gì. Google measures Khi hữu ích nội dung xuất hiện ( chỉ số được gọi là Largest Contentful Paint), và đó part của Core Web Vitals — nhỏ tín hiệu xếp hạng. So render-blocking các tài nguyên có thể hurt cả hai của bạn khách truy cập’ experience và, indirectly, của bạn SEO.
đơn giản các cách sửa
- Thêm
deferđể scripts so họ download alongside trang và chạy sau khi nó drawn. - không put nhiều hơn CSS hoặc JavaScript trong
<head>hơn đầu tiên screen thực ra cần. - nếu bạn’re on WordPress, plugin như WP Rocket hoặc Autoptimize làm điều này cho bạn với checkbox.
Muốn mechanics — async so với defer, cốt yếu CSS, crawl-budget angle, và
Điều gì Google thực ra nói? Chuyển để Nâng cao tab.
Evidence for this claim Stylesheets participate in the critical rendering path and can block first render until CSS is processed. Scope: Current official or standards documentation. Confidence: high · Verified: web.dev: Critical rendering path Evidence for this claim Classic scripts without async or defer can block HTML parsing while fetched and executed. Scope: Current official or standards documentation. Confidence: high · Verified: MDN: script elementTL;DR — Render-blocking các tài nguyên delay một trang đầu tiên paint. An applicable CSS stylesheet trong đó
<head>chặn theo mặc định (non-matchingmedia,disabled, hoặc dynamic insertion với không rõ ràngblocking="render"không). MỘT parser-inserted classic<script>không cóasync/deferlà parser-blocking by default — pausing HTML phân tích cú pháp — mà là một related nhưng distinct mechanism từ đó formal “render-blocking” (bản dịch) «render-blocking» thuộc tính model.asyncloads trong parallel và executes khi downloaded (unordered, có thể interrupt phân tích cú pháp);deferloads trong parallel và executes sau đó HTML là parsed (trong order); module scripts defer theo mặc định. Những delays có thể push lại FCP và LCP, và LCP là dùng by Google xếp hạng các hệ thống — nhưng đây là một tiebreaker, không một dominant factor, và Google documents không trực tiếp render-blocking xếp hạng weight. Google fetches nhiều nhất 2 MB theo non-PDF URL (including các header), riêng cho mỗi referenced JS/CSS file — một truncation boundary, không một render-blocking-cụ thể hình phạt — và all eligible 200-status các trang enter Google kết xuất queue liệu hoặc không they dùng JavaScript. Tìm blockers với đó hiện tại Lighthouse 13 “Render-blocking requests” (bản dịch) «Render-blocking các yêu cầu» Insight và đó DevTools Coverage tab; cách sửa vớidefer, cốt yếu CSS chỉ nơi một trace cho thấy đây là đó bottleneck,mediacác thuộc tính, và removing unused code — thì re-kiểm thử với một repeated, khớp trace.
cốt yếu kết xuất path
Để draw một trang, một trình duyệt chạy một fixed sequence: parse đó HTML vào đó DOM, parse đó CSS vào đó CSSOM, combine them vào một render tree, lay điều này out, và paint. Đó sequence là đó cốt yếu kết xuất path, và bất cứ điều gì đó stalls điều này delays đó đầu tiên pixel. As Google Ilya Grigorik được diễn đạt điều này, “optimizing the critical rendering path refers to prioritizing the display of content that relates to the current user action.” (bản dịch) «optimizing đó cốt yếu kết xuất path refers để prioritizing đó display of nội dung đó relates để đó hiện tại người dùng hành động.» Render-blocking các tài nguyên là đó điều sitting trong đó path với của họ hand lên, đang làm đó trình duyệt chờ.
CSS là render-blocking theo mặc định — Khi nó applicable
Đó trình duyệt sẽ không paint styled nội dung until điều này có đó CSSOM được xây dựng từ mỗi
applicable blocking stylesheet, và MDN’s <link> reference là rõ ràng về đó
phạm vi: “only link elements in the document’s <head> can possibly block
rendering. By default, a link element with rel="stylesheet" in the <head>
blocks rendering when the browser discovers it during parsing.” (bản dịch) «chỉ elements trong đó document thẻ head có thể possibly block kết xuất. Theo mặc định, một element với trong đó thẻ head chặn kết xuất khi đó trình duyệt discovers điều này during phân tích cú pháp.» Từ web.dev
Optimize LCP hướng dẫn: “Style sheets loaded from the HTML markup will block
rendering of all content that follows them.” (bản dịch) «Style sheets loaded từ đó HTML markup sẽ block kết xuất of all nội dung đó follows them.» Này là intentional — việc vẽ
unstyled HTML đầu tiên và re-styling điều này produces an ugly flash — nhưng “theo mặc định”
có real edges:
- stylesheet với non-matching
mediathuộc tính (e.g.media="print"on screen visit) là fetched nhưng không block. - stylesheet với
disabledđặt không phải loaded hoặc applied cho đến khi bạn clear thuộc tính. - stylesheet đã thêm dynamically qua script không phải render-blocking trừ khi bạn cũng
đặt
blocking="render"on nó explicitly — dynamic insertion opts out của default.
Trong của nó applicable phạm vi, bloated blocking stylesheet có thể vẫn hold toàn bộ trang hostage: Khi nó takes lâu hơn để load hơn của bạn LCP image itself, LCP element có thể’t render ngay cả sau khi của nó own tài nguyên có finished downloading.
Scripts: parser-blocking theo mặc định, formally render-blocking on yêu cầu
MỘT parser-inserted classic <script> trong đó <head> không có async hoặc defer là
parser-blocking theo mặc định: đó trình duyệt dừng building đó DOM, fetches đó
script, executes điều này, và chỉ thì resumes. Google legacy PageSpeed tài liệu spell out
đó cost: “whenever the parser encounters a script it has to stop and execute it
before it can continue parsing the HTML. In the case of an external script the
parser is also forced to wait for the resource to download, which may incur one or
more network roundtrips and delay the time to first render of the page.” (bản dịch) «bất cứ khi nào đó parser encounters một script điều này có để dừng và execute điều này trước điều này có thể continue phân tích cú pháp đó HTML. Trong đó case of an external script đó parser là cũng forced để chờ cho đó tài nguyên để download, mà có thể incur một hoặc hơn network roundtrips và delay đó time để đầu tiên render of đó trang.» As đó
Optimize LCP hướng dẫn diễn đạt điều này bluntly, “it is almost never necessary to add
synchronous scripts… to the <head> of your pages.” (bản dịch) «điều này là gần như không bao giờ necessary để thêm synchronous scripts… để đó thẻ head of của bạn các trang.»
Worth đang precise ở đây: parser-blocking và đó HTML spec formal
render-blocking thuộc tính model là related nhưng distinct mechanisms. Theo MDN’s
<script> reference, đó blocking="render" token “explicitly indicates that
certain operations should be blocked until the script has executed,” (bản dịch) «explicitly indicates đó certain operations nên là blocked until đó script có executed,» và “only
script elements in the document’s <head> can possibly block rendering” (bản dịch) «chỉ elements trong đó document thẻ head có thể possibly block kết xuất» này
way — “if such a script element is added dynamically via script, you must set
blocking = "render" for it to block rendering.” (bản dịch) «nếu such một element là đã thêm dynamically qua script, bạn phải set cho điều này để block kết xuất.» Trong thực tế, một default
parser-blocking <head> script đã stalls đó pipeline đủ đó
phân biệt rarely thay đổi điều gì bạn làm về điều này; điều này matters mainly cho dynamically
inserted scripts, mà cần đó rõ ràng thuộc tính để participate, và trình duyệt
hỗ trợ cho blocking="render" là vẫn limited và worth kiểm tra trước khi bạn rely
on điều này.
Một nhiều hơn default worth knowing: type="module" scripts defer theo mặc định (không
defer thuộc tính needed) trừ khi async là đã thêm để thay đổi đó scheduling.
async so với defer — họ không phải giống nhau
Đây là single phần lớn hữu ích phân biệt cho sửa render-blocking JS. Cả hai download script trong parallel với HTML phân tích cú pháp, so neither là parser-blocking during download. họ differ trong execution:
async— executes immediately Khi download finishes, mà có thể interrupt phân tích cú pháp, và chạy trong không guaranteed order. Good cho truly independent thứ ba-party scripts (phân tích, quảng cáo) đó không touch của bạn DOM hoặc phụ thuộc on mỗi khác.defer— executes sau khi HTML là fully parsed, trong document order. Good cho scripts đó phụ thuộc on DOM hoặc on mỗi khác (phần lớn của bạn own code).- Module scripts (
type="module") — deferred theo mặc định; thêmasyncnếu bạn cụ thể muốn module-ready-order execution thay vì.
nếu bạn remember một rule: defer cho bất cứ điều gì ordered hoặc DOM-phụ thuộc, async
chỉ cho fire-và-forget thứ ba-party scripts.
Cách điều này ảnh hưởng SEO
chain là thực nhưng có thực boundaries. không overstate nó trong either direction:
- Render-blocking các tài nguyên delay Đầu tiên Contentful Paint — khi bất kỳ nội dung đầu tiên xuất hiện.
- They có thể delay Largest Contentful Paint — Google chính loading chỉ số — though một flagged tài nguyên không proof đây là đó dominant trường bottleneck, và removing điều này không bảo đảm một tốt hơn LCP; đó Lighthouse Insight các báo cáo một potential delay từ một observed trace, không một guaranteed trường effect.
- LCP là một Core Web Vitals chỉ số, measured tại đó 75th percentile of real trường dữ liệu over 28 days, và Google says Core Web Vitals “are used by our ranking systems.” (bản dịch) «là dùng by của chúng ta xếp hạng các hệ thống.» Đó “good” LCP ngưỡng là ≤2,5 s.
- Google trang-experience tài liệu không define một trực tiếp render-blocking xếp hạng weight, chain, hoặc tiebreaker, và cho không xếp hạng bảo đảm từ removing blockers — điều này says relevance vẫn wins, nhưng “having a great page experience can contribute to success in Search” (bản dịch) «có một great trang experience có thể contribute để success trong Tìm kiếm» khi có lots of similarly helpful nội dung để chọn từ.
Giữ đó weighting honest. Martin Splitt line là đó right calibration: “a fast website is a little more helpful than a slow website,” (bản dịch) «một fast website là một little hơn helpful hơn một chậm website,» nhưng “content is still the king.” (bản dịch) «nội dung là vẫn đó king.» Sửa một tài nguyên đó là genuinely delaying của bạn LCP là worth đang làm cho UX và as một input among nhiều Google các hệ thống weigh — đây là không một lever với một được ghi lại, dedicated xếp hạng multiplier.
crawl-efficiency angle — corrected
I previously được diễn đạt nặng render-blocking JavaScript as điều gì đó “pushes” hoặc “forces” các trang vào Google kết xuất queue. đó là không chính xác, và đây là worth correcting plainly: Google hiện tại JavaScript SEO tài liệu trạng thái đó “all pages with a 200 HTTP status code are sent to the rendering queue, no matter whether JavaScript is present on the page.” (bản dịch) «all các trang với một 200 HTTP mã trạng thái là đã gửi để đó kết xuất queue, không quan trọng liệu JavaScript là present on đó trang.» Mỗi eligible trang goes qua đó queue — render-blocking các tài nguyên không tạo một special on-ramp vào điều này.
Evidence for this claim Google's current guidance says all eligible pages returning HTTP 200 enter its rendering queue regardless of whether JavaScript is present, so render-blocking JavaScript should not be claimed to force a page into that queue. Scope: crawling, rendering, indexing Confidence: high · Verified: Understand the JavaScript SEO basicsĐiều gì đó tài nguyên loại làm thay đổi là cách nhiều hoạt động happens khi một trang reaches kết xuất. Onely thử nghiệm được tìm thấy Google needed 9× lâu hơn để fully crawl JavaScript-được kết xuất các trang hơn giống hệt HTML các trang (313 hours so với. 36 hours) trong của họ kiểm thử setup, vì “pages that require rendering have to wait in a rendering queue in addition to the crawl queue which applies to all pages.” (bản dịch) «các trang đó require kết xuất có để chờ trong một kết xuất queue ngoài ra để đó crawl queue mà áp dụng để all các trang.» Treat đó as evidence đó nội dung requiring client-side kết xuất carries một real time-để-chỉ mục cost trong đó nghiên cứu — không as proof đó một cụ thể render-blocking CSS hoặc JS file là điều gì triggers queueing.
On file size: Google crawling tài liệu mô tả một 2 MB fetch limit theo
non-PDF URL, including HTTP các header, applied riêng để mỗi riêng lẻ
tài nguyên điều này các yêu cầu — so một lớn <head> script hoặc stylesheet nhận của nó own 2 MB
counter, không một shared budget với đó HTML. đó là một fetch/truncation boundary,
không một “processing limit,” (bản dịch) «processing limit,» và Google không document một special crawl hoặc lập chỉ mục
hình phạt tied cụ thể để render-blocking các tài nguyên beyond đó chung
truncation risk.
Worth debunking trong khi chúng ta là ở đây: Google renderer có không fixed timeout. As I’ve được ghi lại trong my JavaScript SEO hướng dẫn, “there is no fixed timeout for the renderer. It runs with a sped-up timer to see if anything is added at a later time.” (bản dịch) «có không fixed timeout cho đó renderer. Điều này chạy với một sped-lên timer để see nếu bất cứ điều gì là đã thêm tại một sau đó time.» Đó concern không một 5-second cutoff — đây là đó queueing delay trước kết xuất ngay cả begins.
Này ngay cả reaches AI các crawler hiện tại. Gary Illyes argued trong 2026 đó “if sites used relatively good HTML and no JavaScript (or SSR), both base model training, and web and agentic RAG would be a piece of cake from raw data processing perspective.” (bản dịch) «nếu các trang dùng relatively good HTML và không JavaScript (hoặc SSR), cả hai base model training, và web và agentic RAG sẽ là một piece of cake từ thô dữ liệu processing perspective.» Nặng client-side JS là một vấn đề well beyond Googlebot.
Cách tìm them
- Chrome DevTools Performance panel / Lighthouse 13 — đó hiện tại “Render
blocking requests” (bản dịch) «Render blocking các yêu cầu» Insight (mà, as of Lighthouse 13, là nơi đó older
“Eliminate render-blocking resources” (bản dịch) «Eliminate render-blocking các tài nguyên» audit moved) flags scripts trong đó
<head>bị thiếuasync/defervà stylesheets không có mộtdisabledhoặc non-matchingmediathuộc tính, và estimates đó ms bạn’d save từ một observed trace. Connor Clark ghi-lên diễn đạt điều này plainly: “render-blocking requests are network requests that prevent a page’s initial render, potentially delaying Largest Contentful Paint.” (bản dịch) «render-blocking các yêu cầu là network các yêu cầu đó ngăn một trang ban đầu render, potentially delaying Largest Contentful Paint.» Nếu bạn là reading older PageSpeed Insights output đó vẫn says “Eliminate render-blocking resources,” (bản dịch) «Eliminate render-blocking các tài nguyên,» đây là đó giống nhau underlying tín hiệu dưới đó pre-Lighthouse-13 name. - Chrome DevTools Coverage tab — marks bytes green (cốt yếu — dùng cho đầu tiên paint) hoặc red (unused tại đầu tiên paint). Lots of red CSS/JS là của bạn candidate list.
- WebPageTest waterfall — xem mọi thứ trước đó Bắt đầu Render line.
- Chạy điều này hơn khi — một single trace reflects đó chạy consent-manager state, bên thứ ba tag load, bộ nhớ đệm state, và CSP behavior. Repeat đó trace (cold và warm) trước treating một flagged tài nguyên as một fixed fact.
An illustrative navigation contains HTML from 0 to 180 milliseconds, blocking CSS from 120 to 420 milliseconds, synchronous JavaScript from 210 to 610 milliseconds, a non-blocking analytics request from 250 to 500 milliseconds, and font loading from 420 to 610 milliseconds. First paint occurs at 610 milliseconds. The example explains timing mechanics; it is not a live trace.
Cách khắc phục them
JavaScript
defernon-cốt yếu scripts —<script src="app.js" defer></script>. Parallel download, ordered execution sau khi parse. safe default cho của bạn own JS.asynccho independent thứ ba-party scripts —<script src="analytics.js" async></script>. chỉ Khi order và DOM-readiness genuinely không quan trọng.- Move scripts để end của
<body>— older fallback Khi Bạn có thể’t thêm các thuộc tính; parser reaches them cuối cùng.
CSS — as conditional decisions, không blanket patterns
- Inline cốt yếu CSS chỉ khi một trace cho thấy CSS là đó thực tế bottleneck —
extract đó styles needed cho trên-đó-fold nội dung vào an inline
<style>block so đầu tiên paint cần không round-trip. Google own caution áp dụng: “inlining CSS is an advanced performance technique that can improve performance, but can also lead to bugs if not implemented properly.” (bản dịch) «inlining CSS là an advanced performance technique đó có thể improve performance, nhưng có thể cũng lead để bugs nếu không implemented properly.» Inline chỉ đó cốt yếu subset, name an owner cho regenerating điều này khi templates thay đổi, và kiểm tra cho drift trên trang trạng thái — một cốt yếu-CSS snapshot đó goes stale silently reintroduces flashes of unstyled nội dung hoặc bị thiếu styles. - Defer đó rest, matching đó yêu cầu chính xác — load đó đầy đủ stylesheet với
đó
<link rel="preload" as="style" onload="this.rel='stylesheet'">pattern. MỘT preload chỉ nhận reused cho đó eventual yêu cầu nếu đó URL,as,type, vàcrossorigin/CORS chế độ match — một mismatched hint gây ra đó trình duyệt để fetch đó tài nguyên twice thay vì skipping đó round-trip. mediacác thuộc tính —media="print"hoặcmedia="(min-width: 900px)"lets đó trình duyệt download một stylesheet không có blocking render khi đó query không match.- Xóa unused CSS và minify — ít hơn để block on, nhanh hơn downloads.
- Verify trước shipping — re-kiểm tra cho duplicate/unused fetches, FOUC, và new layout shift sau bất kỳ cốt yếu-CSS hoặc preload thay đổi, on một repeated trace, không một single lucky chạy.
Nền tảng-cụ thể (WordPress) — WP Rocket (delay/defer JS, optimize CSS phân phối),
Autoptimize (async/defer JS, inline cốt yếu CSS), và Async JavaScript implement all
của trên qua plugin UI. họ’re applying giống nhau async/defer/cốt yếu-CSS
techniques — knowing Điều gì mỗi setting làm là Cách bạn tránh breaking của bạn theme.
Related reading on điều này trang web
- Core Web Vitals — parent chỉ số đặt điều này rolls lên vào.
- Largest Contentful Paint — chỉ số render-blocking các tài nguyên hit hardest.
- đầu tiên Contentful Paint — đầu tiên điều họ delay.
- Total Blocking Time — main-chuỗi trao đổi cost của nặng JS.
- PageSpeed Insights — tool đó surfaces audit.
- Kết xuất và Ngân sách crawl — crawl/render queue angle.
AI summary
condensed take on Nâng cao version:
- Render-blocking các tài nguyên là CSS và synchronous JavaScript on đó cốt yếu
kết xuất path. An applicable stylesheet (
<head>, matchingmedia, khôngdisabled, không dynamically inserted) là render-blocking theo mặc định; một parser-inserted<script>không cóasync/deferlà parser-blocking by default, mà là related để nhưng formally distinct từ đó HTML specblocking="render"thuộc tính (head-chỉ; bắt buộc cho dynamically inserted scripts/stylesheets). async= parallel download, executes khi ready, unordered, có thể interrupt phân tích cú pháp — dùng cho independent bên thứ ba scripts.defer= parallel download, executes sau parse, trong order — dùng cho của bạn own/DOM-phụ thuộc code. Module scripts (type="module") defer theo mặc định.- SEO chain: they có thể delay FCP và LCP (một flagged tài nguyên không proof đây là đó dominant bottleneck); LCP là dùng by Google Core Web Vitals xếp hạng các hệ thống (good ≤2,5 s). Google documents không trực tiếp render-blocking xếp hạng weight hoặc bảo đảm — “a fast website is a little more helpful… content is still the king.” (bản dịch) «một fast website là một little hơn helpful… nội dung là vẫn đó king.»
- Crawl angle, corrected: all eligible 200-status các trang enter Google kết xuất queue regardless of JavaScript presence — render-blocking các tài nguyên không tạo một special queue on-ramp. Google fetches nhiều nhất 2 MB theo non-PDF URL (including các header), theo tài nguyên — một fetch/truncation boundary, không một render-blocking-cụ thể processing hình phạt. Onely nghiên cứu được tìm thấy Google took 9× lâu hơn để fully crawl JS-được kết xuất các trang hơn HTML trong của họ kiểm thử — evidence of một kết xuất-step cost, không proof một cụ thể blocker triggers queueing. Không fixed renderer timeout — đó cost là queueing, không một cutoff.
- Tìm: Lighthouse 13’s “Render blocking requests” (bản dịch) «Render blocking các yêu cầu» Insight (formerly “Eliminate render-blocking resources” (bản dịch) «Eliminate render-blocking các tài nguyên»); DevTools Coverage tab (green = cốt yếu, red = unused); WebPageTest waterfall trước Bắt đầu Render. Repeat đó trace — consent, bên thứ ba, và bộ nhớ đệm state có thể thay đổi kết quả chạy để chạy.
- Cách sửa:
defernon-cốt yếu JS,asyncindependent bên thứ ba JS; inline cốt yếu CSS chỉ nơi một trace cho thấy đây là đó bottleneck (với an owner cho giữ điều này trong sync) và defer đó rest, matching preloadas/type/crossoriginchính xác;mediacác thuộc tính cho conditional stylesheets; xóa unused CSS và minify; verify với một repeated, khớp trace trước shipping.
Tài liệu chính thức
Chính-nguồn hướng dẫn từ Google và Bing.
Google / Chrome
- Render blocking các yêu cầu (Chrome DevTools Performance Insights) — hiện tại có thẩm quyền explainer (Connor Clark, Oct 2025), và Lighthouse 13 Insight điều này topic hiện tại lives dưới: defer, inline, reduce payload.
- Eliminate render-blocking các tài nguyên (legacy Lighthouse audit) — vẫn trực tiếp nhưng carries banner đó nó moved vào Insight trên as của Lighthouse 13; kept ở đây cho readers on older các báo cáo.
- Optimize Largest Contentful Paint — Cách render-blocking CSS và synchronous scripts delay LCP (Philip Walton & Barry Pollard).
- Cốt yếu kết xuất path — underlying parse → CSSOM → render-tree → paint sequence (Ilya Grigorik).
- Xóa render-blocking JavaScript (legacy PageSpeed tài liệu) — deprecated PSI v4, nhưng parser-blocking mechanics là vẫn chính xác.
- Core Web Vitals & Google Search — LCP thresholds và Cách CWV relate để xếp hạng.
- Understand JavaScript SEO basics — xác nhận all eligible 200-status các trang enter kết xuất queue regardless của JavaScript presence.
- Understanding trang experience trong Google kết quả tìm kiếm — hiện tại, bounded language on Cách Core Web Vitals relate để xếp hạng (không trực tiếp render-blocking weight được ghi lại).
HTML / trình duyệt spec (mechanics)
<script>: Script element (MDN) —async/defersemantics, module default-defer, vàblocking="render"thuộc tính (head-chỉ; bắt buộc cho dynamically inserted scripts).<link>: External tài nguyên Link element (MDN) — stylesheetmedia/disabledbehavior,blockingthuộc tính, và preloadas/type/crossoriginyêu cầu-matching requirements.- HTML tiêu chuẩn — script element (WHATWG) — formal parser-blocking và render-blocking definitions điều này bài viết script section là dựa trên.
Bing / Microsoft
- bingbot Series: JavaScript, Dynamic Kết xuất, và Cloaking — Vì sao JS tại quy mô là hard cho Bingbot, và dynamic kết xuất as acceptable workaround (Fabrice Canel & Frédéric Dubut).
- Bing Quản trị viên web Guidelines — trang speed as xếp hạng factor; minimizing render-blocking JavaScript.
Quotes từ nguồn
On—record statements. mỗi link deep-links để quoted passage nơi nguồn trang cho phép nó.
Google / Chrome — mechanics
- “The goal is to reduce the impact of these render-blocking URLs by inlining critical resources, deferring non-critical resources, and removing anything unused.” (bản dịch) «Đó goal là để reduce đó impact of những render-blocking URLs by inlining cốt yếu các tài nguyên, deferring non-cốt yếu các tài nguyên, và removing bất cứ điều gì unused.» — Chrome Lighthouse tài liệu. Nhảy đến trích dẫn
- “Render-blocking requests are network requests that prevent a page’s initial render, potentially delaying Largest Contentful Paint (LCP).” (bản dịch) «Render-blocking các yêu cầu là network các yêu cầu đó ngăn một trang ban đầu render, potentially delaying Largest Contentful Paint (LCP).» — Connor Clark, Chrome DevTools Performance Insights. Nhảy đến trích dẫn
- “Style sheets loaded from the HTML markup will block rendering of all content that follows them.” (bản dịch) «Style sheets loaded từ đó HTML markup sẽ block kết xuất of all nội dung đó follows them.» — web.dev, Optimize LCP (Philip Walton & Barry Pollard). Nhảy đến trích dẫn
- “It is almost never necessary to add synchronous scripts (scripts without the async or defer attributes) to the head of your pages.” (bản dịch) «Điều này là gần như không bao giờ necessary để thêm synchronous scripts (scripts không có đó async hoặc defer các thuộc tính) để đó head of của bạn các trang.» — web.dev, Optimize LCP. Nhảy đến trích dẫn
- “Optimizing the critical rendering path refers to prioritizing the display of content that relates to the current user action.” (bản dịch) «Optimizing đó cốt yếu kết xuất path refers để prioritizing đó display of nội dung đó relates để đó hiện tại người dùng hành động.» — Ilya Grigorik, web.dev, Cốt yếu kết xuất path. Nhảy đến trích dẫn
- “Avoid and minimize the use of blocking JavaScript, especially external scripts that must be fetched before they can be executed.” (bản dịch) «Tránh và minimize đó dùng of blocking JavaScript, especially external scripts đó phải được fetched trước they có thể là executed.» — Google PageSpeed Insights tài liệu (legacy). Nhảy đến trích dẫn
- “All pages with a 200 HTTP status code are sent to the rendering queue, no matter whether JavaScript is present on the page.” (bản dịch) «All các trang với một 200 HTTP mã trạng thái là đã gửi để đó kết xuất queue, không quan trọng liệu JavaScript là present on đó trang.» — Google, Understand đó JavaScript SEO basics.
- “Only
scriptelements in the document’s<head>can possibly block rendering” (bản dịch) «Chỉ elements trong đó document thẻ head có thể possibly block kết xuất» và, cho dynamic insertion, “you must setblocking = "render"for it to block rendering.” (bản dịch) «bạn phải set cho điều này để block kết xuất.» — MDN,<script>: Đó Script element.
Bing / Microsoft
- “It is difficult for bingbot to process JavaScript at scale on every page of every website, while minimizing the number of HTTP requests.” (bản dịch) «Điều này là difficult cho bingbot để xử lý JavaScript tại quy mô on mỗi trang of mỗi website, trong khi minimizing đó number of HTTP các yêu cầu.» — Fabrice Canel & Frédéric Dubut, Microsoft Bing. Nhảy đến trích dẫn
Ngành research — crawl-queue cost
- “Pages that require rendering have to wait in a rendering queue in addition to the crawl queue which applies to all pages.” (bản dịch) «Các trang đó require kết xuất có để chờ trong một kết xuất queue ngoài ra để đó crawl queue mà áp dụng để all các trang.» — Ziemek Bućko, Onely (Google needed 9× lâu hơn để crawl JS hơn HTML). Nhảy đến trích dẫn
- “You can do this by deferring the loading of non-critical CSS and JavaScript files needed for ‘below the fold’ content until later.” (bản dịch) «Bạn có thể làm này by deferring đó loading of non-cốt yếu CSS và JavaScript files needed cho ‘dưới đó fold’ nội dung until sau đó.» — Joshua Hardwick, Ahrefs. Nhảy đến trích dẫn
Render-blocking khắc phục checklist
Hoạt động top để bottom — diagnose đầu tiên, sau đó khắc phục highest-savings items.
- Chạy PageSpeed Insights / Lighthouse và open đó hiện tại “Render blocking requests” (bản dịch) «Render blocking các yêu cầu» Insight (Lighthouse 13; older các báo cáo có thể vẫn label điều này “Eliminate render-blocking resources” (bản dịch) «Eliminate render-blocking các tài nguyên»); note đó estimated ms savings theo tài nguyên as một lead, không phải là bảo đảm.
- Open đó DevTools Coverage tab và reload — flag stylesheets/scripts đó là mostly red (unused tại đầu tiên paint).
- Thêm
deferđể mỗi non-cốt yếu<script>đó phụ thuộc vào đó DOM hoặc on other scripts. - Dùng
asyncchỉ cho genuinely independent bên thứ ba scripts (analytics, quảng cáo) — không bao giờ cho ordered hoặc DOM-phụ thuộc code. - Xác nhận không synchronous
<script>sits trong đó<head>không cóasync/defer. - Inline chỉ đó cốt yếu (trên-đó-fold) CSS; load đó rest với đó
preload+onloadpattern — không inline mọi thứ. - Thêm
mediacác thuộc tính để conditional stylesheets (print, breakpoint các truy vấn) so they download không có blocking. - Xóa unused CSS và minify all CSS/JS để shrink download time.
- Giữ riêng lẻ JS/CSS files well dưới Google 2 MB theo-URL fetch limit (bao gồm HTTP các header; đây là một truncation boundary, không một render-blocking hình phạt, nhưng một truncated file có thể vẫn break behind đó scenes).
- Re-kiểm thử on một repeated, khớp trace (bộ nhớ đệm/consent/bên thứ ba state có thể shift kết quả) và kiểm tra trường LCP — aim để land LCP ≤2,5 s tại đó 75th percentile.
- Sanity-kiểm tra đó trang visually sau CSS inlining — đây là đó step hầu hết có khả năng để introduce bugs.
Render-blocking bảng tra nhanh
async so với defer so với đơn giản <script>
| Thuộc tính | Chặn parser? | Download | Execution order | sử dụng cho |
|---|---|---|---|---|
none (sync <script>) | Có | Pauses phân tích cú pháp để fetch | Immediately, chặn render | Gần như không bao giờ trong <head> |
async | Không (during download) | Parallel | Khi ready — unordered, có thể interrupt parse | Independent thứ ba-party scripts (phân tích, quảng cáo) |
defer | Không | Parallel | sau khi HTML parsed — trong document order | của bạn own / DOM-phụ thuộc code |
là điều này tài nguyên render-blocking?
| tài nguyên | Render-blocking? | Cách un-block nó |
|---|---|---|
<link rel="stylesheet"> trong <head>, applicable | Có (default) | Non-matching media, disabled, hoặc preload+onload |
<link media="print"> (on screen visit) | Không | (đã non-blocking) |
| Stylesheet inserted dynamically qua script | Không, trừ khi blocking="render" đặt | Thêm blocking="render" chỉ nếu bạn cụ thể cần nó để block |
Sync <script> trong <head> (không async/defer) | Parser-blocking theo mặc định | Thêm defer (hoặc async nếu independent) |
<script defer> / <script async> / <script type="module"> | Không | — |
| Inline cốt yếu CSS | Không | (đó point — giữ nó nhỏ) |
Fast facts
- LCP “good” ngưỡng: ≤ 2,5 s tại đó 75th percentile of trường dữ liệu (28-day window).
- Google fetches nhiều nhất 2 MB theo non-PDF URL (including các header), được tính riêng cho mỗi referenced JS/CSS file — một fetch/truncation boundary, không một được ghi lại render-blocking-cụ thể hình phạt.
- All eligible 200-status các trang enter Google kết xuất queue regardless of liệu JavaScript là present — render-blocking các tài nguyên không tạo một special queue on-ramp.
- Google renderer có không fixed timeout — đó cost là đó kết xuất queue, không một cutoff.
- Lighthouse 13’s “Render blocking requests” (bản dịch) «Render blocking các yêu cầu» Insight (formerly đó “Eliminate
render-blocking resources” (bản dịch) «Eliminate render-blocking các tài nguyên» audit) flags head scripts bị thiếu
async/defer, và stylesheets không códisabled/ non-matchingmedia, từ một observed trace — re-kiểm thử để xác nhận. - DevTools Coverage: green = cốt yếu, red = unused tại đầu tiên paint.
- Inlining CSS là advanced — inline chỉ đó cốt yếu subset nơi một trace cho thấy đây là đó bottleneck; inlining all of điều này kills bộ nhớ đệm và gây ra bugs.
- Preload chỉ nhận reused nếu
as/type/crossoriginmatch đó eventual yêu cầu — một mismatch gây ra một duplicate fetch.
Diagnose render-blocking các vấn đề by symptom
trang vẫn giữ blank trước khi appearing all tại sau khi
có khả năng nguyên nhân: stylesheet hoặc synchronous head script là holding đầu tiên paint. khắc phục: inspect document sớm yêu cầu chain, sau đó defer non-cốt yếu JavaScript và split hoặc reduce non-cốt yếu CSS. xác nhận: new trace paints hữu ích nội dung trước khi những điều đó non-cốt yếu files finish.
defer đã làm không improve đầu tiên paint
có khả năng nguyên nhân: CSS hoặc một synchronous script là vẫn cốt yếu blocker, hoặc deferred script không phải bottleneck. khắc phục: so sánh trước khi/sau khi yêu cầu chain và main-chuỗi trao đổi activity thay vì assuming mỗi script chặn kết xuất. xác nhận: remaining cốt yếu path identifies tiếp theo tài nguyên đó gates paint.
trang flashes unstyled sau khi deferring CSS
có khả năng nguyên nhân: styles needed cho ban đầu viewport là moved out của cốt yếu path. khắc phục: giữ truly cốt yếu CSS khả dụng cho đầu tiên render và defer chỉ rules không needed tuy vậy. xác nhận: throttled filmstrip hiển thị styled nội dung từ đầu tiên painted frame.
khắc phục improves FCP nhưng tạo layout shifts
có khả năng nguyên nhân: deferred styles hoặc muộn component initialization thay đổi geometry sau khi paint. khắc phục: bảo toàn sizing và layout-cốt yếu rules trong ban đầu render. xác nhận: nhanh hơn đầu tiên paint vẫn và Layout Shifts track hiển thị không new instability.
audit flags khác tài nguyên on tiếp theo chạy
có khả năng nguyên nhân: consent-manager gating, thứ ba-party tag load order, CSP, service-worker bộ nhớ đệm, hoặc đơn giản bộ nhớ đệm state changed Điều gì đã nhận discovered hoặc executed giữa chạy — single trace không phải vĩnh viễn classification. khắc phục: repeat trace trên trạng thái đó quan trọng (đầu tiên visit so với. được lưu đệm, consent accepted so với. declined) trước khi treating một chạy flagged tài nguyên as khắc phục đích. xác nhận: giống nhau tài nguyên vẫn hiển thị as dominant blocker trên khớp, repeated traces.
Simplified render-blocking các ví dụ
Parser-blocking script versus deferred script
đầu tiên script dừng HTML phân tích cú pháp. thứ hai downloads trong parallel và chờ cho đến khi phân tích cú pháp là hoàn tất.
<!-- Blocks the parser -->
<script src="app.js"></script>
<!-- Better for a script that depends on the parsed document -->
<script defer src="app.js"></script>Một stylesheet cho mỗi viewport versus conditional CSS
media thuộc tính giữ print-chỉ stylesheet từ blocking screen render.
<link rel="stylesheet" href="screen.css">
<link rel="stylesheet" href="print.css" media="print">Cốt yếu styles trước khi deferred bundle
điều này simplified pattern làm nhỏ ban đầu layout khả dụng immediately. Production implementations vẫn cần kiểm thử cho CSP, bộ nhớ đệm, và flashes của unstyled nội dung.
<style>
.site-header { min-height: 4rem; }
</style>
<link rel="stylesheet" href="site.css"> Prompt: classify cốt yếu các tài nguyên
Paste DevTools Network export hoặc list của document sớm CSS và JavaScript các yêu cầu.
Act as a web-performance reviewer. Classify each supplied CSS or JavaScript
resource as required for the first viewport, required after HTML parsing, or
non-critical. For every classification, cite the evidence present in my input.
Recommend only one of: keep blocking, defer, async, conditional media, split,
or remove. Flag anything you cannot decide without inspecting runtime behavior.
Do not assume that every stylesheet or script is safe to delay.
INPUT:
[paste the request list, initiators, timing, and what the resource controls]Prompt: review implementation diff
Review this HTML/CSS/JavaScript diff for render-path regressions. Check script
ordering, DOM dependencies, critical CSS coverage, flashes of unstyled content,
layout-shift risk, duplicate downloads, and failure when JavaScript is delayed.
Return a table with: finding, evidence from the diff, user-visible risk, test to
run, and safest correction. Do not invent page behavior not shown in the input.
DIFF:
[paste the diff] List potentially blocking head các tài nguyên
Paste điều này vào DevTools Console. kết quả là audit queue, không instruction để defer mọi thứ.
const headResources = [...document.head.querySelectorAll('link[rel="stylesheet"], script[src]')]
.map((element) => ({
type: element.tagName.toLowerCase(),
url: element.href || element.src,
async: element.tagName === 'SCRIPT' ? element.async : undefined,
defer: element.tagName === 'SCRIPT' ? element.defer : undefined,
media: element.tagName === 'LINK' ? element.media || 'all' : undefined,
}));
console.table(headResources);tìm các tài nguyên đó finished trước khi đầu tiên paint
const firstPaint = performance.getEntriesByName('first-contentful-paint')[0]?.startTime;
console.table(
performance.getEntriesByType('resource')
.filter((entry) => firstPaint && entry.responseEnd <= firstPaint)
.map((entry) => ({ name: entry.name, type: entry.initiatorType, end: Math.round(entry.responseEnd) }))
);các tài nguyên trong điều này list consumed time trước khi FCP, nhưng timing alone không prove đó tài nguyên blocked kết xuất. xác nhận với trace và dependency chain.
Tools cho finding render blockers
- PageSpeed Insights và Lighthouse: identify render-blocking yêu cầu opportunities trong repeatable lab chạy. Treat estimated savings as lead thay vì bảo đảm.
- Chrome DevTools Performance panel: connect các yêu cầu, HTML phân tích cú pháp, script execution, style calculation, và đầu tiên painted frame on một timeline.
- Chrome DevTools Network panel: inspect yêu cầu priority, initiators, timing, giao thức, bộ nhớ đệm behavior, và order trong mà cốt yếu files arrive.
- Chrome DevTools Coverage panel: tìm unused CSS và JavaScript trong recorded journey. Coverage từ một route không phải permission để delete code được sử dụng elsewhere.
- WebPageTest: so sánh waterfalls và filmstrips dưới khác locations và connection profiles.
hữu ích workflow là Lighthouse cho clue, Performance và Network panels cho nguyên nhân, sau đó throttled trước khi/sau khi recording cho proof.
Prove render-blocking khắc phục worked
Deferred-script kiểm thử
Kiểm thử để chạy: record cold, throttled load trước khi và sau khi thêm defer, sau đó inspect phân tích cú pháp và đầu tiên paint. Dự kiến kết quả: HTML phân tích cú pháp continues trong khi script downloads và trang vẫn initializes correctly sau khi phân tích cú pháp. thất bại interpretation: script phụ thuộc vào immediate execution hoặc ordering là changed incorrectly. Monitoring window: immediate trong repeated traces. Rollback trigger: bị thiếu nội dung, JavaScript các lỗi, hoặc hỏng interactions.
Conditional-stylesheet kiểm thử
Kiểm thử để chạy: load mỗi relevant viewport và media chế độ trong khi recording Network và Performance panels. Dự kiến kết quả: non-matching CSS không delay screen đầu tiên render, trong khi matching layouts vẫn styled. thất bại interpretation: cốt yếu rules là placed trong sai bundle hoặc media condition là incomplete. Monitoring window: immediate trên supported breakpoints. Rollback trigger: unstyled nội dung, không đúng print output, hoặc new layout shifts.
Cốt yếu-path so sánh
Kiểm thử để chạy: so sánh giống nhau trang, device profile, và cold-bộ nhớ đệm conditions trước khi và sau khi thay đổi, và repeat mỗi side của so sánh thay vì relying on single trace. Dự kiến kết quả: blocking chain và FCP/LCP timing improve consistently trên khớp, repeated chạy thay vì trong một lucky chạy. thất bại interpretation: variance, một bottleneck, hoặc runtime-state khác biệt (consent state, thứ ba-party tag timing, CSP, service-worker bộ nhớ đệm) giải thích apparent gain. Monitoring window: several controlled lab chạy, followed by trường monitoring. Rollback trigger: trường LCP, CLS, các lỗi, hoặc conversion behavior worsens sau khi phát hành.
Tự kiểm tra: Render-Blocking các tài nguyên
Five nhanh các câu hỏi on render-blocking CSS và JavaScript. Pick câu trả lời cho mỗi, sau đó kiểm tra.
Nhật ký thay đổi
Đã cập nhật 8 thg 8, 2026.
Tóm tắt biên tập và chi tiết thay đổi đã ghi nhận.Chi tiết thay đổi
-
Ghi chú thay đổi chi tiết hiện chỉ có bằng tiếng Anh.
Không thể so sánh đầy đủ — không có bản lưu trước đó cho lần sửa đổi này.
Đã cập nhật 27 thg 7, 2026.
Tóm tắt biên tập và chi tiết thay đổi đã ghi nhận.Chi tiết thay đổi
-
Ghi chú thay đổi chi tiết hiện chỉ có bằng tiếng Anh.
Không thể so sánh đầy đủ — không có bản lưu trước đó cho lần sửa đổi này.
Đã cập nhật 18 thg 7, 2026.
Tóm tắt biên tập và chi tiết thay đổi đã ghi nhận.Chi tiết thay đổi
-
Ghi chú thay đổi chi tiết hiện chỉ có bằng tiếng Anh.
-
Ghi chú thay đổi chi tiết hiện chỉ có bằng tiếng Anh.
-
Ghi chú thay đổi chi tiết hiện chỉ có bằng tiếng Anh.
-
Ghi chú thay đổi chi tiết hiện chỉ có bằng tiếng Anh.
-
Ghi chú thay đổi chi tiết hiện chỉ có bằng tiếng Anh.
Không thể so sánh đầy đủ — không có bản lưu trước đó cho lần sửa đổi này.