Consider a compressed Javascript file (containing few merged javascript files) called compressed.js. This file could be called using: <script src="javascripts/compressed.js" type="text/javascript"></script> Afriend of mine said that placing the following code in the footer would be better in terms of the site performance:
<div id="footer:>
<script type="text/javascript">
//Compressed js code is located here
</script>
</div>
</body>
</html>
Is he right? Any answers and links concerning the javascript performance improving are greatly appreciated
Javascript, by definition, is client side, so (in most cases) there’s no point loading it before the website has been delivered to the browser and laid out.
If you load it in the footer it doesn’t increase the performance of the javascript, what it does it allows the page to download and load in the browser before you load the javascript. This can be done by reference or by inclusion in the code, however its always better to have the javascript in an external file so that it doesn’t increase the size of the html page you’re delivering to the browser.