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

Faster page load: delay rendering codemirror until in view #2885

Merged
merged 4 commits into from
Apr 11, 2024

Conversation

fonsp
Copy link
Owner

@fonsp fonsp commented Apr 8, 2024

Render the code as plaintext (with some fake codemirror classes) until the input is scrolled into view, instead of creating the codemirror on page load.

This makes the page load faster (LCP from 720ms to 560ms) and the page becomes interactive faster (busy CPU time from 2070ms to 1020ms).

The number of elements in the page goes down (from 8409 to 5206, or 4506 when also skipping folded cells).

This also makes SSR easier if we ever want to do that in the future.

Before

Scherm­afbeelding 2024-04-08 om 12 10 28

After

Scherm­afbeelding 2024-04-08 om 12 10 44

TODO

  • detect print
  • skip optimization for the first 5 cells
  • start loading in background when idle
  • Cross-navigating cells with arrow keys should still work
  • Investigate skipping render for folded cells
  • frontend tests

@fonsp fonsp added frontend Concerning the HTML editor CM6 CodeMirror 6 performance labels Apr 8, 2024
Copy link
Contributor

github-actions bot commented Apr 8, 2024

Try this Pull Request!

Open Julia and type:

julia> import Pkg
julia> Pkg.activate(temp=true)
julia> Pkg.add(url="https://github.com/fonsp/Pluto.jl", rev="delay-cm-until-scrolled-into-view")
julia> using Pluto

@fonsp fonsp changed the title Delay rendering codemirror until in view Faster page load: delay rendering codemirror until in view Apr 11, 2024
@fonsp fonsp merged commit 6a61511 into main Apr 11, 2024
3 checks passed
@fonsp fonsp deleted the delay-cm-until-scrolled-into-view branch April 11, 2024 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CM6 CodeMirror 6 frontend Concerning the HTML editor performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant