It is always recommended to avoid inline Javascript codes by putting all codes in a JS
file, which is included in all pages. I wonder, if this does not cause pe
You should read about unobtrusive javascript, http://en.wikipedia.org/wiki/Unobtrusive_JavaScript.
There are other solutions for not loading all the javascript files in your assets directory for each webpage, one called requirejs that should check out, http://requirejs.org/ .
Moreover as a general rule of thumb you should not be adding all your event listeners when page loads, what about dom objects that don't exist? It will throw up javascript errors and will break your code more than usual.