Skip to content

Use inline block for digits - #355

Merged
jared-hughes merged 1 commit into
mainfrom
digit-perf
Jul 31, 2026
Merged

Use inline block for digits#355
jared-hughes merged 1 commit into
mainfrom
digit-perf

Conversation

@jared-hughes

Copy link
Copy Markdown

This improves performance in Chrome. Something about the negative margins made Chrome take quadratic time in the layout step. This is part of why 10k element lists were really slow. After this PR, they should take closer to 1 second to render, rather than 1 minute.

The negative margins were the lines below used for digit grouping, like margin-right: @contract-margin; (since contract-margin is -0.009em).

@mikehaverstock mikehaverstock left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Have you verified this doesn't change anything meaningful with rendering? We could, for instance, fire off a job to compare a lot of latex rendering to make sure it's pixel perfect. I'm not good enough with css to know why this is obviously only a performance optimization and not going to change layout.

@mikehaverstock

Copy link
Copy Markdown
Member

How did you come up with this?

@jared-hughes

Copy link
Copy Markdown
Author

Removed all the digit classes and saw the performance was good, then bisected what styles could be the culprit to determine that removing the margins would fix up performance. I then brainstormed a few possible alternatives to using margins:

  1. padding (nope, doesn't fix performance)
  2. width: ... + transform: translateX(...). This required display: inline-block to get the width to apply.
  3. padding + display: inline-block (yep, fixes performance)
  4. Just display: inline-block (yep, fixes performance)

@jared-hughes
jared-hughes merged commit 7bfab4b into main Jul 31, 2026
2 checks passed
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