Answer the question
In order to leave comments, you need to log in
Write error with async js, how to fix?
Comrade friends, greetings.
I insert an adsense ad block on the site, everything is as always, but for some reason the Google console swears:
Failed to execute 'write' on 'Document': It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened.
Loaded with the async option.
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
Answer the question
In order to leave comments, you need to log in
In fact, it was not about async. It's just that Google increased the activation time of the ad several times. Previously, it appeared after 5 minutes, now half an hour passed between the status change "New" → "Active" and everything worked by itself.
In short, remove async
A long time ago in scripts, you could do document.write() during script execution and this would complement the current document. The async attribute says that the script can be loaded and executed asynchronously and, accordingly, such behavior is not allowed with it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question