What is the difference between the following two codes in an HTML file? If I add one more javascript file xyz.js after including the abc.js, is there any priority associated when the scripts are being used?
First code:
<script src="js/abc.js" type="text/javascript" language="javascript"> </script>
Second code:
<script language="javascript">
/*same code of abc.js*/
</script
The primary difference is that the javascript file can be cached by the browser and network devices so the user doesn’t have to download it on every page load.
So if you have 100k of javascript files, your visitor only needs to download them once. Otherwise, they’d have to download those same exact 100k every page load and visit.
This allow applies to inline and external CSS and images as well!!
Granted this is only the tip of the iceburg of caching and browser performance (Steve’s book is one of the web ‘bibles’):
http://yuiblog.com/blog/2006/11/28/performance-research-part-1/
http://www.yuiblog.com/blog/2007/01/04/performance-research-part-2/
http://www.stevesouders.com/