0

Hello a have an add that is loaded with a simple script tag:

<script src="http://...(external)" type="text/javascript" language="Javascript">

It contains something like :

document.write('...(some html code)');

The problem is that this script execution is blocking. In the case that the ad domain is not reachable, the page containing this add is only displayed, once the timeout is reached.

I tried to load the script asynchronously with <script async and with <script defer, but this keeps the content from being added.

Is there a way I can change this script to be loaded in a non-blocking way ? Or is the way the ad provider uses (document.write) just evil ?

Lorenz Meyer
  • 19,166
  • 22
  • 75
  • 121
  • You could put it at the bottom of the page. That way it will block as late as possible. It is generally a good idea to put external Javascript files at the bottom of the page anyway. – Sverri M. Olsen Mar 12 '15 at 11:18
  • The simplest option is to put it in an iframe. – georg Mar 12 '15 at 11:53
  • @sverri Put the JavaScript at the bottom of the page is not an option because it is replaced by the ad using `document.write()` – Lorenz Meyer Mar 12 '15 at 11:58
  • @georg It's not clear for me how to add this script in an iframe. Can you give an example code ? – Lorenz Meyer Mar 12 '15 at 12:58
  • @LorenzMeyer: make a dummy html file on your server like `` and load this file into iframe. – georg Mar 12 '15 at 13:05

0 Answers0