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
Post a Comment