Skip to content

mjx-row > * CSS style has impact on large documents #3463

@krassowski

Description

@krassowski

Issue Summary

When very large documents which include mathjax are edited the mjx-row > * contributes to the high cost of style recalculation.

Most of the CSS selectors in MathJax are neatly scoped, use child combinator (>), and avoid using universal selector (*), which altogether makes recent versions of MathJax quite performant when it comes to style calculation. However this one rule stands out:

'mjx-row > *': { display: 'table-cell' }

https://github.com/mathjax/MathJax-src/blob/1a2ef74c0ac0620e7b8de46402c9dce3b95ade52/ts/output/chtml.ts#L150

I see that elsewhere mjx-row > mjx-cell is used. Is the use of the universal selector here intentional, or was it just a placeholder when the code was initially written?

For context, this rule was initially added in mathjax/MathJax-src#50

Steps to Reproduce:

  1. Create an HTML document with deep nesting and high number of DOM nodes
  2. Load MathJax
  3. Enable CSS statistics collection in Chrome/Edge Performance tab
  4. Start Chrome profiler
  5. Make any modification to the DOM
  6. See that a few ms can be spent in "Recalculate Styles" on matching mjx-row > *

Technical details:

  • MathJax Version: 3.0+
  • Browser: Chrome and Edge 141

Supporting information:

Irrelevant

Metadata

Metadata

Assignees

No one assigned

    Labels

    AcceptedIssue has been reproduced by MathJax teamCode ExampleContains an illustrative code example, solution, or work-aroundMergedMerged into develop branchv4

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions