Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selector Performance #25

Open
saxamaphone69 opened this issue Jan 18, 2023 · 6 comments
Open

Selector Performance #25

saxamaphone69 opened this issue Jan 18, 2023 · 6 comments

Comments

@saxamaphone69
Copy link
Owner

https://blogs.windows.com/msedgedev/2023/01/17/the-truth-about-css-selector-performance/

After reading this article, ran it through the Edge DevTools.

Keep it mind that some of the selectors are actually from uBlock.

Screenshot 2023-01-18 105311
Screenshot 2023-01-18 105553
Screenshot 2023-01-18 105615

.stub ~ *
:where(b, strong, th, legend, .subject, .name)
.fileText .file-info:has(.fnswitch)
:where(button, input, option, select, textarea)

On page load seem to be the most expensive.

Other notable selectors are

::selection
*
::before
:disabled
:root
::after
::-webkit-scrollbar-thumb
::-webkit-scrollbar
.fileText .file-info a:has(> .fnswitch)
.globalMessage *
.catalog-post .postlnfo *
.pagelist .pages:not(.cataloglink) *
.catalog-post [class^="qmark"]
.fileText a
.file:hover .fileText
:root:not(.bottom-backlinks) .container.not(:empty)::before
#fourchanx-settings legend + *
.postNum > a:first-child
.catalog-post > .postInfo > :not(.subject):not(.nameBlock):not(.dateTime)
#qr .oekaki-bg > *
.stub ~ :not(.threadDivider)

Keep it mind this is with 4x CPU throttling, but faster CSS is faster CSS regardless of throttle.

Also to keep in mind is this appears to only really happen in threads with over 150 replies.

@saxamaphone69
Copy link
Owner Author

In a 250 post thread,

Using

.stub + .replacedSideArrows,
.stub + .replacedSideArrows + .post
	display none

takes it under 2500µs.

The original CSS

/* .stub ~ * is probably a little too expensive $$$ - but it's there because
 if json index is off and replies are shown, it covers all bases */
.stub ~ *
	display none

takes 21000µs.

Is the 0.02 seconds (which is 4x slower than normal) in savings worth it?

@saxamaphone69
Copy link
Owner Author

:where(b, strong, th, legend, .subject, .name)

In a 400 post thread, 13500µs with 13106 match attempts but only 400 found.

Without :where(), as in just b, strong, th, legend, .subject, .name pings once for the single .subject on the page, and 205µs for .name, with 404 counts for 404 attempts.

@saxamaphone69
Copy link
Owner Author

Also, some of those selectors are the original 4chan X CSS that loads, renders, then gets removed.

@saxamaphone69
Copy link
Owner Author

Using the free version of Project Wallace:

image

image

image

image

Though I'm sure the paid version would tell me which of these are more complex. I also am writing in .styl so I don't see the CSS.

image

@saxamaphone69
Copy link
Owner Author

Using https://isellsoap.github.io/specificity-visualizer/ I had to remove :has() that started with > or +, so for example :has(> .fnswitch) and :has(+ .poster-mod).

image

image

A lot of them are red because of poor naming conventions on 4chan X's side and are out of my control (inconsistent naming, lack of generic classes).

image

Some of them are probably my fault.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant