fluentui icon indicating copy to clipboard operation
fluentui copied to clipboard

Performance: Stack.Horizontal.Wrap.Example.tsx has bad CSS example lead to bad browser performance.

Open LiangMingChen opened this issue 7 years ago • 2 comments

Environment Information

  • Package version(s): (fill this out)
  • Browser and OS versions: (fill this out if relevant)

Please provide a reproduction of the bug in a codepen:

Actual behavior:

I am Code Reviewing peer's change and flag the browser render engine (Edge, Blink, Trident) potential rendering engine over head, He point out he copy that from the Sample code.

https://github.com/OfficeDev/office-ui-fabric-react/blob/1b705beb1cad712f93da2954511b7d6a1d583797/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.Wrap.Example.tsx#L22

This is out of experience from working with Edge perf lead. In general, CSS should avoid <tag> name. It is especially worst when it is last of the CSS rule.

  1. Browser tend to optimize for div/span with class name (Hash)
  2. Browser tend eval the rule to apply form right to left. --- when you specified rule end with <span> that lead to Hash look up failed, end up gather every <span> on the page!! then leading down to bad browser performance.

This example happen to hit both. In general, example should avoid performance pitfall.

Expected behavior:

Change to the last <span> a class name

https://github.com/OfficeDev/office-ui-fabric-react/blob/1b705beb1cad712f93da2954511b7d6a1d583797/packages/office-ui-fabric-react/src/components/Stack/examples/Stack.Horizontal.Wrap.Example.tsx#L22

Priorities and help requested:

Are you willing to submit a PR to fix? (Yes, No)

Requested priority: (Blocking, High, Normal, Low)

Products/sites affected: (if applicable)

LiangMingChen avatar Jun 08 '19 03:06 LiangMingChen

@LiangMingChen thank you for reporting this issue! This is a valid concern and we are looking into this.

Rajeev-K avatar Jun 10 '19 18:06 Rajeev-K

:tada:This issue was addressed in #9403, which has now been successfully released as [email protected].:tada:

Handy links:

msft-github-bot avatar Jun 12 '19 22:06 msft-github-bot