Just for the sake of experimentation, I've been trying to determine different ways to non-destructively chain window.onload
functions in a web browser. This is the idea of what I have so far:
var load = window.onload;
var newFunction = function(){
alert("ha!");
}
window.onload = function(){
load();
newFunction();
}
The problem I see with this is that every time you chain a function, it adds another level of function calls to the stack. Is there a better way to go about this that doesn't add unnecessary depth to the call stack?