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

IE11 / Edge performance issues with using attribute selectors #339

Open
aaronnuu opened this issue Oct 23, 2017 · 3 comments
Open

IE11 / Edge performance issues with using attribute selectors #339

aaronnuu opened this issue Oct 23, 2017 · 3 comments

Comments

@aaronnuu
Copy link

Hi,

I have been using glamor to help build a medium sized application and when testing in IE and Edge I noticed a major performance issue when hovering over elements with the ':hover' pseudo-selector OR hovering over their parent element. After many hours of debugging and one helpful medium article I discovered that the issue is caused by IE recalculating layout for almost every element on the page when using attribute selectors.

The first screenshot is with the '[data-css-*]' attribute selector:
screen shot 2017-10-23 at 1 57 58 pm

The second screenshot is after removing those selectors from my stylesheet:
screen shot 2017-10-23 at 2 42 58 pm

As you can see at a minimum the browser spent 65x less time calculating layout without the [data-css-*] selectors...

This is quite an extreme example as I am testing in a VM on a development build but using the reasonably powerful 2017 surface studio I was still getting ~350ms of layout calculation on every hover event.

I know the feature to opt-out of using those attribute selectors is on the backlog however I'm not sure if you are aware of exactly the performance impact they have on IE and Edge browsers, as this makes glamor basically unusable for even a medium sized application.

Cheers

@aaronnuu aaronnuu changed the title IE11 / Edge performance issues IE11 / Edge performance issues with using attribute selectors Oct 23, 2017
@compulim
Copy link

compulim commented Dec 5, 2017

@AaronW9090 I would like to know more about the perf issue.

Do you mean glamor has perf impact on Edge when:

  1. Creating new rules with attribute selector, i.e. calling css({ ... }) and applying as <div { ...style }>
  2. The attribute-based rule is turned on by a pseudo class, i.e. mouse hovering over an element with [data-css-XXX]:hover style

Even though I am not using attributed-based version (i.e. <div { ...rootStyle }>), but only class name-based rule (i.e. <div className={ rootStyle }>) across all my elements, will it affect overall performance on Edge?

@aaronnuu
Copy link
Author

aaronnuu commented Dec 5, 2017

@compulim If your elements don't have the [data-css-xxx] attribute then even if those selectors appear in your stylesheet you shouldn't have these perf issues (although I haven't tested this).

@nolanlawson
Copy link

Hi all, this appears to be a known issue with Edge which we're working on: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/13348719/

In the meantime, it may be advantageous to look into using classes instead of attributes. Classes should be faster than attributes in all engines, and particularly faster in Edge/IE. In general, most engines have optimized more for classes and IDs than for attributes.

I also advised Svelte to do the same FWIW: sveltejs/svelte#1118

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

3 participants