Say I have some mobile check at the very top of my script:
if (isMobile) {
window.location.href = '/m/' + window.location.pathname + window.location.search;
}
And I also have some metrics down the code (or even in some other module that is loaded asynchronously) that are being sent to my metrics server.
My question is: how can I stop execution of everything that goes below my window.location
change? Or even better, how to stop the whole javascript engine so that it doesn't execute any other asynchronously loaded modules?
I know that I can do mobile proxying in many different ways, but in this task my mobile redirect must be run on the client side, it is a given.
if (isMobile) {
window.location.href = '/m/' + window.location.pathname + window.location.search;
return;
}
It's simple: return false
...
if (isMobile) {
window.location.href = '/m/' + window.location.pathname + window.location.search;
return false;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With