It will work, due to javascript's function scope. But you're right in that I should move the source before the if to make this clear.