M
M
My joy2016-04-20 14:50:04
JavaScript
My joy, 2016-04-20 14:50:04

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>

How can this be fixed?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
My joy, 2016-04-20
@t-alexashka

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.

F
fetis26, 2016-04-20
@fetis26

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 question

Ask a Question

731 491 924 answers to any question