fonsp / Pluto.jl

🎈 Simple reactive notebooks for Julia
https://plutojl.org/
MIT License
4.91k stars 284 forks source link

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

Closed fonsp closed 2 months ago

fonsp commented 2 months ago

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

github-actions[bot] commented 2 months ago

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