Skip to content

Do not put things into :root to avoid bad performance of _repr_html_#1847

Merged
SimonHeybrock merged 5 commits intomainfrom
css-performance-fix
Apr 21, 2021
Merged

Do not put things into :root to avoid bad performance of _repr_html_#1847
SimonHeybrock merged 5 commits intomainfrom
css-performance-fix

Conversation

@SimonHeybrock
Copy link
Copy Markdown
Member

@SimonHeybrock SimonHeybrock commented Apr 20, 2021

After #1794 creating HTML output had become laggy, and it got worse the more cells a notebook contained. Lag was in the 0.5 s to > 1 s range, once a notebooks contained dozens of cells or more.

The root cause seems to be placement of CSS custom properties (colors in this case) in :root.

@SimonHeybrock SimonHeybrock changed the title Do not put things into :root to avoid bad performance of __repr_html__ Do not put things into :root to avoid bad performance of _repr_html_ Apr 20, 2021
@jl-wynen
Copy link
Copy Markdown
Member

I moved the custom property definitions into sc-root for two reasons, sc-wrap is used in two places in the HTML repr and it doesn't make sense to use it for tables because it adds extra styling.

for key, val in config['colors'].items()})


def _preprocess_style(template: str) -> str:
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Copy Markdown
Member Author

@SimonHeybrock SimonHeybrock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried after the latest changes, still fixes the problem. 👍

@SimonHeybrock SimonHeybrock merged commit a8c0230 into main Apr 21, 2021
@SimonHeybrock SimonHeybrock deleted the css-performance-fix branch April 21, 2021 06:54
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

Successfully merging this pull request may close these issues.

2 participants