Hacker News new | ask | show | jobs
by claytongulick 315 days ago
There are a few different ways.

One really easy way is to put a custom element at the root of the dom and just add/remove event listeners, maybe one-shot if that's all you need.

I also have a convenient little library called ApplicationState [1], which basically does the same thing but can persist state in indexdb.

Lots of other libraries out there too.

[1] https://claytongulick.github.io/applicationstate/