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

Remove Button Ripple in default theme to boost perf #5587

Closed
fzaninotto opened this issue Nov 25, 2020 · 2 comments
Closed

Remove Button Ripple in default theme to boost perf #5587

fzaninotto opened this issue Nov 25, 2020 · 2 comments
Assignees

Comments

@fzaninotto
Copy link
Member

fzaninotto commented Nov 25, 2020

Problem

On complex pages (e.g. a datagrid with 100+ rows and several buttons per row), each render takes several seconds. When profiling with Chrome and React profiler, it appears that a significant share of that rendering time is spent on the button ripple effect.

The ripple effect is mostly useful on Mobile, where there is no "click" feeling. But react-admin is mostly designed for desktop use

Solution

Disable the ripple effect by default by using mui themes. The users can still re-enable it if they want.

Don't forget to replace the focus style by something else, as explained in the Mui Button documentation:

image

Proof of concept

In https://codesandbox.io/s/hopeful-cdn-0op29?file=/src/index.js, the PostList displays 100 rows

With debug tools turned on, a rerender of the list takes 4.5s on average (measured across 6 runs).

I disabled the ripple by passing a custom theme, as explained in https://material-ui.com/customization/globals/#default-props:

const theme = createMuiTheme({
  props: {
    // Name of the component ⚛️
    MuiButtonBase: {
      // The default props to change
      disableRipple: true, // No more ripple, on the whole application 💣!
    },
  },
});

With debug tools turned on, a rerender of the list takes 3,2s on average (measured across 6 runs).

That's a net performance boost of (4.5 - 3,2) / 4.5 = 29%. Yep, you read that right.

Disabling TouchRipple on Buttons makes complex pages 29% faster

Edit: The initial benchmark had a mistake, so the measure boost is 29%, not 38%.

@fzaninotto fzaninotto self-assigned this Nov 27, 2020
fzaninotto added a commit that referenced this issue Nov 27, 2020
@djhi
Copy link
Collaborator

djhi commented Nov 30, 2020

Fixed by #5598

@djhi djhi closed this as completed Nov 30, 2020
djhi pushed a commit that referenced this issue Dec 7, 2020
@VityaSchel
Copy link

How to enable it again? 😳

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