I have a script that replaces certain text with a hyperlink and it works perfect if I put the javascript code at the footer, but if I put the javascrpt in an external file it won't work. For example here is the body section of the code that works (when the JS is in the footer) <body> one of these words will be replaced with a link <script type="text/javascript"> (function($) { var thePage = $("body"); thePage.html(thePage.html().replace(/replace/ig, '<a href="http://google.com">word</a>')); })(jQuery) </script> </body> Code (markup): That works, however since I am going to be using this on many different pages I would rather link to the javascript file instead of having it on the page. I have tried this and it doesn't work (I just copied and pasted the same JS code onto the javascript.js file): <body> one of these words will be replaced with a link <script type='text/javascript' src='javascript.js'></script> </body> Code (markup): And then the javascript.js file (the file I'm linking to is the exact same: <script type="text/javascript"> (function($) { var thePage = $("body"); thePage.html(thePage.html().replace(/replace/ig, '<a href="http://google.com">word</a>')); })(jQuery) </script> Code (markup): I'm using I'd have to modify the script to open the page where I am going to replace the text? Any help would be awesome!