This 'quantum weirdness" starts becoming apparent as the script grows in complexity, especially as more info gets written to the browser web page.
There is no magic fix, but you can keep struggling on for a while so long as you are aware that you will be pushing an overloaded wonky wheel-barrow across a sagging plank which will get ever more likely to collapse under the strain and ever steeper the further you go.
The first signs of quantum weirdness are when doing a SAVE causes the esp device to reboot. Even though it may have returned a 'Saved ok' confirmation after reconnection, there is now a real possibility that the saved file is corrupted, so it's best not to load the script back from the device using EDIT in order to prevent loading corruption, and make sure that you frequently save the script to computer text file.
Typically, every alternate SAVE will cause a device reboot. I found this unworkable with Chrome, but Firefox eventually reconnects back up to the rebooted device and the web page becomes responsive again, offering the opportunity for doing another SAVE, which hopefully this time will return a 'Saved ok' confirmation without causing the device to reboot.
Even if your script has SAVEd ok it may not RUN properly. Typically it may not correctly display all elements of the web page, ie: some may have incorrect lengths and widths or missing backrounds etc. Many times, simply doing a browser BACK then another RUN may display things correctly (or with different errors) but other times those same errors persist until another successful non-rebooting SAVE is performed.
You can lighten the load by temporarily 'commenting out' completed but non-crucial chunks of script, or you can even create your own 'debug flags' to temporarily avoid displaying some things to screen, with the eventual intention of putting everything back in place once each chunk is debugged and working.
So it may be possible to continue development for quite some time by 2nd SAVEing again directly after a reboot, but with the caveat that the web page may eventually display correctly, but not necessarilly first time each time.
If you reach the stage where the second alternate SAVE does not correct the display errors, you are now teetering on the brink of total collapse. You might just manage to keep going a bit longer by doing 2 good SAVES in quick succession after the rebooted SAVE, or you might scrape things along a bit more my powering off the device then back on again and doing a clean successful SAVE without any accumulated VARs baggage.
Continued persistence is now likely to result in Esp_Basic interpreter corruption - which is likely to have you wasting much time chasing ghosts... until you eventually twig the reason for the frustrations, and do an inevitable reformat and reflash. If you haven't achieved your original intentions by now, this would be a good point to re-evaluate and consider compromise or alternatives.