# Avoid Inline JavaScript > Avoid having multiple JavaScript codes embedded in the middle of your body. Regroup your JavaScript code inside external files or eventually in the `` or at the end of your page (before ``). Placing JavaScript embedded code directly in your `` can slow down your page because it loads while the DOM is being built. The best option is to use external files with async or defer to avoid blocking the DOM. Another option is to place some scripts inside your ``. Most of the time analytics code or small script that need to load before the DOM gets to main processing. Ensure that all your files are loaded using `async` or `defer` and decide wisely the code that you will need to inject in your ``. - [11 Tips to Optimize JavaScript and Improve Website Loading Speeds](https://www.upwork.com/hiring/development/11-tips-to-optimize-javascript-and-improve-website-loading-speeds/)