A timeout would most certainly not trigger during a busy loop in JS. Timeouts can only trigger when the main thread is not running code.
Browsers will complain against code running for too long without interruption though.
Browsers will complain against code running for too long without interruption though.
Wow, that seems hard to do. One would need to take a lot of things in account, including recursive calls, asynchronous functions / calls and, indeed, even long strings of instructions that are not necessarily part of a loop or recursive calls.
Would a transform that adds the check between every JS instructions where it is possible theoretically solve the problem? is there a solution that does not slow down the code too much and interrupts the code within an acceptable margin?