It depends on the engine. You need to understand that css and JS are part of the brouwser environment you run your cells in. There are two approaches to handling it:
• cell isolation with separate scripts and JS for each cell (done as iframe or similar)
• global context for the whole page (or even mulitple tabs.
The problem with cell isolation is that you need to repeat custom scripts in each cell. This is especially problematic when your frontend is also written in Kotlin and not distributed via CDN. I had a lot of troubles with that in VisionForge.
Currently, all notebook renderers work differently, which gives a lot of headache for integration developers. I hope that there will be kind of unified approach in future. Right now, the way it works in Jupyter Lab is the most robust.