I thought that JavaScript doesn\'t have block scope, but function scope, and that declarations are hoisted from their block to the top of their parent functions.
How
if (…) { function …() { … } }
is invalid ECMAScript. Function declarations must be on the top level of function or program bodies, inside of blocks their behaviour is implementation-dependent. Firefox does execute this function statement conditionally, other browsers do hoist it like a normal function declaration. Move it outside the if-statement, or assign a function expression.