I need to trigger function bar() whenever function foo() fires. I have no control over function foo or whether it will change in the future. I have this situation regularly (and
You can just override foo with a custom function that calls the original.
foo
E.g.
var old_foo = foo; foo = function() { old_foo(); bar(); }
You should also pass any arguments foo takes into it via your replacement function.