Page 1 of 1

sequence of javascript tag

Posted: Fri Jun 19, 2009 4:37 pm
by tanvirtonu
I just want to know if the following sequence of javascript code is possible.If possible what are the drawbacks and what are the considerations I should remember.

Code: Select all

 
<script type="text/javascript" src="someFile.js"></script>
 
<script type="text/javascript">
// code goes here
</script>
 
<script type="text/javascript" src="anotherFile.js"></script>
 
<script type="text/javascript" src="anotherFile.js"></script>
 
<script type="text/javascript">
// code goes here
</script>

Re: sequence of javascript tag

Posted: Sat Jun 20, 2009 3:31 am
by kaszu
They all will be loaded in an order as they appear in dom. Browser will stop loading page until JS file is loaded and 'evaluated'.
You should consider putting <script> at the bottom of the <body> instead of <head> where they usually are.