0

I have this URL which needs to be loaded after the page has been loaded. I am trying to load the URL via Javascript like this:

<script type="text/javascript" src="//www.adtol.com/native/1/1/0/1"></script>

But, whenever I add async to this script doesn't load.

<script async type="text/javascript" src="//www.adtol.com/native/1/1/0/1"></script>

The src doesn't actually load the js file, it fetches data from server.

What can I do to load the URL asynchrounously via Javascript?

You can visit the src URL for better idea.

Evil Tech
  • 304
  • 2
  • 13
  • Do you get an error on one of your own js files when you add `async`? If that's the case, that's what async itself means i-e. it won't wait to load before your custom script is loaded. – Yousaf Hassan Jun 20 '18 at 06:17
  • 1
    *"But, whenever I add async to this script doesn't load"* `async` is supported by all major browsers (even IE11 -- actually, I think Microsoft created `async`). What do you mean by "doesn't load"? You get an error? You see nothing in the Network panel? I find it extremely unlikely that it just doesn't load. – T.J. Crowder Jun 20 '18 at 06:19
  • See also: https://html.spec.whatwg.org/#attr-script-async – T.J. Crowder Jun 20 '18 at 06:20
  • The `src` is not actually a .js file, it is URL – Evil Tech Jun 20 '18 at 06:20
  • @EvilTech - All `src`s are URLs. But your `//www.adtol.com/native/1/1/0/1` returns JavaScript code, right? That's what your `script` tag says it does. – T.J. Crowder Jun 20 '18 at 06:21
  • How do you know it doesn't load? – Chris Cousins Jun 20 '18 at 06:22
  • @T.J.Crowder The URL actually runs on server side and has a php script and the ouput is written via `document.write`. – Evil Tech Jun 20 '18 at 06:23

0 Answers0