resize-observer icon indicating copy to clipboard operation
resize-observer copied to clipboard

Investigate getComputedStyle performance

Open devrelm opened this issue 7 years ago • 1 comments

It looks like getComputedStyle returns a "live" CSSStyleDeclaration that automatically updates its properties.

It'd be nice to check out how we could use this to our advantage for performance, or whether it might be unnecessary or even bad to do so.

To Do:

  • [ ] What do the specs say?
  • [ ] How do browsers behave?
  • [ ] Can we cache the CSSStyleDeclaration?
  • [ ] Is it even that expensive to call getComputedStyle? (For instance, does the browser already have all these CSSStyleDeclaration objects sitting there, making getComputedStyle basically just a property accessor?)
  • [ ] Does it become expensive to hold onto a bunch of "live" CSSStyleDeclaration objects? (For instance, if the object doesn't exist before calling getComputedStyle, and updates values whether or not we check them, does it end up being worse for performance?)

devrelm avatar Aug 10 '18 16:08 devrelm

#10 switched us from using getBoundingClientRect to getComputedStyle.

However, there's a possibility that this will actually result in incorrect values, so we may want to look into using clientWidth and clientHeight instead.

devrelm avatar Aug 10 '18 21:08 devrelm