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

Performance Problems with getComputedStyle() (Layout Thrashing). #480

Open
kaladay opened this issue Nov 5, 2021 · 0 comments
Open

Performance Problems with getComputedStyle() (Layout Thrashing). #480

kaladay opened this issue Nov 5, 2021 · 0 comments

Comments

@kaladay
Copy link
Contributor

kaladay commented Nov 5, 2021

Tthe getComputedStyle() ends up forcing a layout redraw / reflow, see:

In testing this really seems to happen on calls to getPropertyValue() as seen here:

Consider the strategy from the referenced issues:

- Don't call getComputedStyle as much as possible.
- Don't call it in a loop (multiple force render.)
- If you have to have do it.
  a. do it at the debounce & after request animation frame. (Thus blink is already eval most of the data that you ask for.)
  b. stamp the class that you are looking for rather than ask the style to get for it.

Not to mention, according to the specs (https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle) the values may be intentially incorrect.

...Returned values are sometimes deliberately inaccurate. To avoid the “CSS History Leak” security issue, browsers may lie about the computed styles for a visited link, returning values as if the user never visited the linked URL...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant