CodeblockCustomizer icon indicating copy to clipboard operation
CodeblockCustomizer copied to clipboard

CSS selectors performance issue

Open dimateos opened this issue 3 months ago • 3 comments

When I drag a file, worse if it seats at the root of the vault, there is quite a noticeable lag. I profiled it with css selector stats and seems like this plugin uses too much global selectors?

Not sure how it could it be improved, but probably should only be injecting CSS styles inside a editor tab, and not other kinds of editor leaves.

  • Regular selector starts: takes like 30ms (profiler with selector starts slows everything down tho) Image

  • With this plugin: takes like 130ms (references to style-sheet-XXX-17 are linked to the plugin) Image


So other plugins/themes/snippets also produce slowdowns due to CSS selections

  • e.g. in this testing environment the Excalidraw plugin increases the selector to 60ms

But I think it could be improved for this plugin

Regards

dimateos avatar Sep 21 '25 11:09 dimateos

Yes, I totally agree. I have to be hones, I hate CSS, and don't even know that good. But I will look at it. Most of the time when a lagging is noticable it is a wrong CSS selector. Which theme are you using? (That is also often a factor)

mugiwara85 avatar Sep 21 '25 11:09 mugiwara85

The default one. With a few snippets that increase the test from 15ms to 30ms, so it seems fine. This only happened when dragging a file around so it's not horrible tho.

dimateos avatar Sep 21 '25 12:09 dimateos

It definitely could be improved. As I said, I hate CSS, so I did definitely some things not correctly. I will debug, maybe I can find out, which one causes issues.

mugiwara85 avatar Sep 21 '25 16:09 mugiwara85