A browser will execute code after window.location.href = 'http://google.com until the browser goes to the next web address. As such, the number of lines that will be executed depends on some combination of the browsers speed or later synchronous input from the user (an alert in your case).