Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Tổng quan
Đảm bảo rằng tập lệnh thư viện thẻ quảng cáo đang được yêu cầu một cách bảo mật. Điều này không chỉ
mang lại khả năng bảo mật tốt hơn cho người dùng mà còn cải thiện hiệu suất. Kể từ quảng cáo
yêu cầu do GPT đưa ra luôn sử dụng HTTPS, tải chính thư viện từ
máy chủ lưu trữ được đề xuất thông qua HTTPS đảm bảo rằng
trình duyệt chỉ cần mở 1 kết nối cho tất cả các yêu cầu liên quan đến việc phân phát quảng cáo.
Đề xuất
Luôn tải tập lệnh thẻ quảng cáo từ một URL HTTPS.
Không chính xác
<script>
var el = document.createElement('script');
// Incorrect: potentially loading the ad tag over HTTP.
var useSSL = 'https:' == document.location.protocol;
el.src = (useSSL ? 'https:' : 'http:') + '//securepubads.g.doubleclick.net/tag/js/gpt.js';
var node = document.getElementsByTagName('script')[0];
node.parentNode.insertBefore(el, node);
</script>
[null,null,["Cập nhật lần gần đây nhất: 2025-07-25 UTC."],[[["\u003cp\u003eLoading ad tag library scripts securely over HTTPS enhances security and performance for users.\u003c/p\u003e\n"],["\u003cp\u003eBrowsers establish a single connection for ad serving when GPT and its library are fetched via HTTPS.\u003c/p\u003e\n"],["\u003cp\u003eAd tag scripts should always be loaded from an HTTPS URL for optimal security.\u003c/p\u003e\n"],["\u003cp\u003eGoogle Publisher Tag and AdSense are among the supported ad tag library scripts, and their HTTPS URLs are provided for reference.\u003c/p\u003e\n"]]],["Ad tag library scripts should be loaded via HTTPS for enhanced security and performance. Always use HTTPS URLs to load scripts; avoid HTTP. Secure loading ensures a single browser connection for all ad-related requests, as GPT uses HTTPS. Supported scripts include those for AdSense (e.g., `pagead2.googlesyndication.com/pagead/js/adsbygoogle.js`) and Google Publisher Tag (e.g., `securepubads.g.doubleclick.net/tag/js/gpt.js`). The correct implementation is loading scripts such as `https://securepubads.g.doubleclick.net/tag/js/gpt.js` using the script tag.\n"],null,["# Load ad tag over HTTPS\n\nOverview\n--------\n\nEnsures that ad tag library scripts are being requested securely. This not only\nprovides better security for your users, it also improves performance. Since ad\nrequests issued by GPT always use HTTPS, loading the library itself from the\n[recommended host](./loads-gpt-from-official-source) via HTTPS ensures that the\nbrowser only needs to open 1 connection for all requests related to ad serving.\n| **Note:** This should only fail on non-secure websites, as most secure websites will automatically load scripts using HTTPS.\n\nRecommendations\n---------------\n\nAlways load your ad tag scripts from an HTTPS URL.\n\n|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| **Incorrect** | ```html \u003cscript\u003e var el = document.createElement('script'); // Incorrect: potentially loading the ad tag over HTTP. var useSSL = 'https:' == document.location.protocol; el.src = (useSSL ? 'https:' : 'http:') + '//securepubads.g.doubleclick.net/tag/js/gpt.js'; var node = document.getElementsByTagName('script')[0]; node.parentNode.insertBefore(el, node); \u003c/script\u003e ``` |\n| **Correct** | ```html \u003cscript async src=\"https://securepubads.g.doubleclick.net/tag/js/gpt.js\"\u003e\u003c/script\u003e ``` |\n\nMore information\n----------------\n\nThe following ad tag library scripts are supported:\n\n| Library | Script(s) |\n|----------------------|-------------------------------------------------------------------------------------------------------------|\n| AdSense | `pagead2.googlesyndication.com/pagead/js/adsbygoogle.js` `pagead2.googlesyndication.com/pagead/show_ads.js` |\n| Google Publisher Tag | `googletagservices.com/tag/js/gpt.js` `securepubads.g.doubleclick.net/tag/js/gpt.js` |\n\n[Get Started with Google Publisher Tags](https://developers.google.com/publisher-tag/guides/get-started) \n[View audit source](https://github.com/googleads/publisher-ads-lighthouse-plugin/tree/HEAD/lighthouse-plugin-publisher-ads/audits/loads-ad-tag-over-https.js) [Improve this article](https://github.com/googleads/publisher-ads-lighthouse-plugin/tree/HEAD/docs/audits/loads-ad-tag-over-https.md) [Report an issue](https://github.com/googleads/publisher-ads-lighthouse-plugin/issues/new?labels=documentation&template=documentation-feedback.md&title=Documentation+feedback%3A+loads-ad-tag-over-https.md)\n\n\u003cbr /\u003e"]]