Page editor saves javascript changes

He||o All

I found a strange behavior of page editor.

In my custom theme I have a JS on page that changes the page DOM, - adds some elements.

I’ve found that those changes are saved in page template in database.

This was really bad in my case - the generated by JS HTML accumulated in the page code.



How could this be avoided? Is there a way to know if the page is currently edited?

He||o All
I found a strange behavior of page editor.
In my custom theme I have a JS on page that changes the page DOM, - adds some elements.
I’ve found that those changes are saved in page template in database.
This was really bad in my case - the generated by JS HTML accumulated in the page code.

How could this be avoided? Is there a way to know if the page is currently edited?