The solution is to add the code to the <head> portion of your file through an external file. If the script loading interrupts the rest of the page load, you may need to change your design structure. Abstracting your code into classes and functions will keep the code from loading unless you tell it to. Any code that you do need loaded automatically can be called on your document's onload event. This way the code will be loaded only after the rest of the file is loaded, and it will still be cached. In libraries like Prototype or JQuery, you can use the document.ready() function.