広告タグを非同期で読み込む
概要
この監査では、広告タグライブラリのスクリプトが非同期的に読み込まれるようにします。
デフォルトでは、JavaScript の実行は同期します。つまり、スクリプトが発生すると、そのスクリプトがダウンロード、解析、実行されるまで他のコンテンツは読み込まれません。非同期で実行するように設定すると、指定したスクリプトがバックグラウンドで読み込まれている間も、ブラウザで他のリソースの処理を続行できるようになります。これにより、ページの応答性を維持できます
重要な部分をすべて読み込むのに必要な時間が
説明します。
推奨事項
スクリプトタグの定義に async 属性を追加します。例:
AdSense
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
AdSense(自動広告)
<script async data-ad-client="ca-pub-xxxxxxxxxxxxxxxx" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
Google パブリッシャー タグ
<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
次の広告タグ ライブラリ スクリプトがサポートされています。
広告タグ ライブラリ |
スクリプト |
AdSense |
pagead2.googlesyndication.com/pagead/js/adsbygoogle.js
pagead2.googlesyndication.com/pagead/show_ads.js
|
Google パブリッシャー タグ |
googletagservices.com/tag/js/gpt.js
securepubads.g.doubleclick.net/tag/js/gpt.js
|
Google パブリッシャー タグを使ってみる
GPT のリクエスト モードと非同期レンダリング
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2024-10-15 UTC。
[null,null,["最終更新日 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."]]],[]]