Caricare il tag annuncio in modo asincrono
Panoramica
Questo controllo garantisce che gli script della libreria di tag annuncio vengano caricati in modo asincrono.
Per impostazione predefinita, l'esecuzione di JavaScript è sincrona. Ciò significa che, una volta che uno script
, nessun altro contenuto può essere caricato finché lo script non è stato
scaricati, analizzati ed eseguiti. L'attivazione dell'esecuzione asincrona impedisce questa operazione, consentendo al browser di continuare a elaborare altre risorse mentre lo script specificato viene caricato in background. In questo modo la pagina rimane reattiva
durante il caricamento degli script e riduce il tempo necessario per caricare tutte
componenti.
Consigli
Includi l'attributo async nella definizione del tag script. Ad esempio:
AdSense
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
AdSense (annunci automatici)
<script async data-ad-client="ca-pub-xxxxxxxxxxxxxxxx" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
Tag publisher di Google
<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
Sono supportati i seguenti script della libreria di tag annuncio:
Libreria di tag annuncio |
Script |
AdSense |
pagead2.googlesyndication.com/pagead/js/adsbygoogle.js
pagead2.googlesyndication.com/pagead/show_ads.js
|
Tag publisher di Google |
googletagservices.com/tag/js/gpt.js
securepubads.g.doubleclick.net/tag/js/gpt.js
|
Inizia a utilizzare i tag publisher di Google
Modalità di richiesta GPT e rendering asincrono
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
Ultimo aggiornamento 2024-10-15 UTC.
[null,null,["Ultimo aggiornamento 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"]]