I use a lot of the same function on multiple pages, and I think a lot of you do to. You can create a common JScript file and load it during an onload event, extending the functionality of your CRM. This is particularly useful because it reduces the amount of changes you have to make when you want to change how something works.
Code reuse is important, and I believe in creating libraries and using libraries. Javascript files are libraries, and they are cached. So if you update a Javascript file you are loading this way, make sure your users clear their cache.
function loadjs(filename, onload){
var scriptfile=document.createElement('script');
scriptfile.setAttribute("type","text/javascript");
scriptfile.setAttribute("src", filename);
scriptfile.onreadystatechange=onload;
document.getElementsByTagName("head")[0].appendChild(scriptfile);
}
loadjs("/MoreJavascript/tools.js", function(){
if (this.readyState == 'loaded' || this.readyState == 'complete') {
FunctionInJavascriptFile();
this.onreadystatechanged=null;
}
});
CRM 2011 uses web-resources which can be a common JScript file.

