Description
As highlighted in jupyterlab/jupyterlab#18076, jupyterlab-myst contributes hundreds of complex and slow selectors which forces browsers to attempt matching thousands of elements each time any DOM modification happens.
Proposed solution
- Do not attach styles globally
- Use Shadow DOM for rendering markdown cells
- Drop the
.myst prefix while in shadow DOM since not needed
- Reuse a single stylesheet between shadow DOMs (Markdown cells)
Additional notes
The panel/bokeh ecosystem is a good example of shadow DOM usage.