Tải thẻ quảng cáo không đồng bộ
Tổng quan
Quá trình kiểm tra này đảm bảo tập lệnh thư viện thẻ quảng cáo được tải không đồng bộ.
Theo mặc định, quy trình thực thi JavaScript là đồng bộ. Điều này có nghĩa là sau khi một tập lệnh
thì không thể tải nội dung nào khác cho đến khi tập lệnh đó được
tải xuống, phân tích cú pháp và thực thi. Việc chọn tham gia thực thi không đồng bộ sẽ ngăn
điều này, cho phép trình duyệt tiếp tục xử lý các tài nguyên khác trong khi
tập lệnh đã chỉ định sẽ tải trong nền. Điều này giúp trang của bạn phản hồi tốt hơn trong khi tập lệnh đang tải và giảm thời gian cần để tải tất cả thành phần quan trọng.
Đề xuất
Đưa thuộc tính không đồng bộ vào định nghĩa thẻ tập lệnh. Ví dụ:
AdSense
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
AdSense (quảng cáo tự động)
<script async data-ad-client="ca-pub-xxxxxxxxxxxxxxxx" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
Thẻ nhà xuất bản của Google
<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
Các tập lệnh thư viện thẻ quảng cáo sau đây được hỗ trợ:
Thư viện thẻ quảng cáo |
(Các) tập lệnh |
AdSense |
pagead2.googlesyndication.com/pagead/js/adsbygoogle.js
pagead2.googlesyndication.com/pagead/show_ads.js
|
Thẻ nhà xuất bản của Google |
googletagservices.com/tag/js/gpt.js
securepubads.g.doubleclick.net/tag/js/gpt.js
|
Bắt đầu sử dụng Thẻ nhà xuất bản của Google
Chế độ yêu cầu GPT (Thẻ nhà xuất bản của Google) và hiển thị không đồng bộ
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2024-10-15 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2024-10-15 UTC."],[[["This audit verifies if ad tag library scripts are loaded asynchronously to improve page performance."],["Asynchronous loading allows the browser to load other content while the script loads in the background, preventing delays and improving user experience."],["To enable asynchronous loading, include the `async` attribute within the `\u003cscript\u003e` tag when implementing ad tags like AdSense and Google Publisher Tag."],["Synchronous loading, where the browser waits for the script to fully load before proceeding, can negatively impact page load times and overall performance."]]],["To optimize page load times, ad tag library scripts should load asynchronously. This is achieved by including the `async` attribute within the `\u003cscript\u003e` tag. Asynchronous loading allows the browser to continue loading other page content while the script downloads and executes in the background. Supported ad tag libraries include AdSense and Google Publisher Tag, with specific script URLs like `pagead2.googlesyndication.com/pagead/js/adsbygoogle.js` and `securepubads.g.doubleclick.net/tag/js/gpt.js` needing the `async` attribute.\n"]]