Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error - Asynchronous adsense code in HTML

I'm a blogger and I monetize my blog with adsense. While coding or in fact adding asynchronous code inside <head></head>tag of my blog it appears that I have to add it like this:

 <script async="async" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>

instead of like this:

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>

Otherwise it will show me an error. Can anyone explain why? Do you know if I'm allowed to add this (according to adsense)?

like image 700
Aws Ahmed Avatar asked Feb 09 '14 16:02

Aws Ahmed


People also ask

How can I paste AdSense code in HTML?

After you've generated the AdSense code, you need to paste it between the <head> and </head> tags of your site. We recommend you place the AdSense code on every page across your site to get the most out of AdSense.

What is asynchronous AdSense code?

The ad code you generate in your AdSense account is fully asynchronous. It offers improved web latency and a better user experience for your site's visitors.

How do you insert ad in HTML?

After you get and copy your ad unit code, you need to paste it between the <body> and </body> tags of your page. If you paste the ad code outside the <body> tags it will prevent your ads from appearing correctly.


2 Answers

Use this code instead on any of them... I'm currently using this...Try it

<script async='async' src='http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js'></script>
like image 200
Muhammad Nouman Khalid Avatar answered Sep 21 '22 04:09

Muhammad Nouman Khalid


You're writing an XHTML document (either because of the Content-Type or an XML declaration).

Therefore, the entire document must be valid XML.

Unlike regular HTML, all XML attributes must have values.

like image 22
SLaks Avatar answered Sep 19 '22 04:09

SLaks