-
-
Notifications
You must be signed in to change notification settings - Fork 293
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
Static HTML: faster page load by preloading statefile #2887
Conversation
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="prefetch-statefile")
julia> using Pluto |
Before this PR, I did Chrome clear all cache, then Chrome dev tools > Performance > measure reload with Fast 3G network throttle on https://featured.plutojl.org/basic/images LCP 7.59s and 7.52s Also did the https://featured.plutojl.org/basic/plutoui.jl Let me know if you want the trace files LCP 5.92s and 5.79s and 5.87 |
Aha! I was using
I also set the crossorigin settings wrong, but now I followed https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel/preload and it seems to work! The statefile is being requested even before the editor! And the |
When viewing a static notebook online (like https://featured.plutojl.org/language/structure%20and%20language ), the statefile is downloaded by the editor and displayed. But this can be optimized! We can download the statefile in parallel to the editor!
Before
You can see the waterfall effect: the request for the statefile happens after the editor has loaded.
After
EDIT we use preload now, see #2887 (comment)
I didn't take the time to test this on a full setup like featured.plutojl.org but I just tested the PlutoSliderServer test server: https://github.com/JuliaPluto/PlutoSliderServer.jl/blob/1c5423e301f26b20000461127c9ab5a15cbdf829/test/runtests.jl#L4-L7
You can see in the network log that the Size column gives (prefetch cache), and the timings are fast (although localhost will always be fast).
Doubts
This article https://web.dev/learn/performance/resource-hints makes me a bit doubtful, it looks like you can easily make the browser download the resource twice... I am not sure when to use the
crossorigin
attribute. I think this is not a cross-origin request? (Since we are allowed to read the response with JS, unlike an opaque CORS requestI tried
preload
andprefetch
, andpreload
did not work,prefetch
seems to work.I am also not able to debug this very well, I can't find the prefetch/preload request in the browser dev tools, only the
fetch
. Maybe just merge and see if featured.plutojl.org is faster?Maybe the type of prefetch should be a setting in PlutoSliderServer?