Memuat tag iklan secara asinkron
Ringkasan
Audit ini akan memastikan bahwa skrip library tag iklan dimuat secara asinkron.
Secara default, eksekusi JavaScript dilakukan secara sinkron. Ini berarti setelah skrip
ditemukan, tidak ada konten lain yang dapat dimuat hingga skrip tersebut selesai
didownload, diurai, dan dieksekusi. Memilih untuk menjalankan eksekusi asinkron akan mencegah
ini, memungkinkan browser untuk terus memproses resource lain sementara
skrip yang ditentukan dimuat di latar belakang. Hal ini akan membuat halaman Anda tetap responsif
selama skrip sedang dimuat, sekaligus mengurangi waktu yang diperlukan untuk memuat semua komponen
penting.
Rekomendasi
Sertakan atribut asinkron dalam definisi tag skrip. Contoh:
AdSense
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
AdSense (iklan Otomatis)
<script async data-ad-client="ca-pub-xxxxxxxxxxxxxxxx" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
Tag Penayang Google
<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
Berikut skrip library tag iklan yang didukung:
Library Tag Iklan |
Skrip |
AdSense |
pagead2.googlesyndication.com/pagead/js/adsbygoogle.js
pagead2.googlesyndication.com/pagead/show_ads.js
|
Tag Google Penayang |
googletagservices.com/tag/js/gpt.js
securepubads.g.doubleclick.net/tag/js/gpt.js
|
Memulai Tag Google Publisher
Rendering asinkron dan mode permintaan GPT
Kecuali dinyatakan lain, konten di halaman ini dilisensikan berdasarkan Lisensi Creative Commons Attribution 4.0, sedangkan contoh kode dilisensikan berdasarkan Lisensi Apache 2.0. Untuk mengetahui informasi selengkapnya, lihat Kebijakan Situs Google Developers. Java adalah merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2024-10-15 UTC.
[null,null,["Terakhir diperbarui pada 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"]]