what are all the different ways to include an external javascript file into a html? -


what different ways include external javascript file html? please give me examples.

thanks in advance.

three possible solutions

standard way

<script type="text/javascript" language="javascript" src="myfile.js"></script> 

via javascript (example)

function loadcoolscript(){   var file=document.createelement('script')   file.setattribute("type","text/javascript")   file.setattribute("src", "http://siteb.com/cool-script-location/cool-script.js")   document.getelementsbytagname("head")[0].appendchild(file) } 

non blocking loading via labjs

<script>    $lab    .script("framework.js").wait()    .script("plugin.framework.js")    .script("myplugin.framework.js").wait()    .script("init.js"); </script> 

Comments

Popular posts from this blog

unicode - Are email addresses allowed to contain non-alphanumeric characters? -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

c++ - Convert big endian to little endian when reading from a binary file -