Defer Loading of External JavaScript

You may also like...

4 Comments

  1. Tedy says:

    Hi Jose,

    Doesn't the HTML "defer" do just the same?
    e.g.
    as seen at: https://www.w3schools.com/tags/att_script_defer.asp

    • Hendy Tarnando says:

      Hi Tedy, there are some differences. The JavaScript function above defers both the download and execution of a script and the script is executed on window's load event, whereas the defer attribute only defer the execution and the script is executed before DOMContentLoaded event. So it depends on your requirements.

  2. Jose Luis says:

    Where should I put the function? head, body, /body?

    Thanks

Leave a Comment

Wrap your code block in <pre class="code"></pre> tag.