Can PyScript lazy loading defer startup until first interaction?
0 reputation · 21 Mar 2024, 00:23 UTC
Design scope
For a PyScript page with occasional user interactions, the goal is to decide whether lazy module loading and WebWorker execution can defer enough startup work to justify the added configuration. This assumes a current PyScript release; the exact version matters because default extensions and loading behavior may vary.
The unresolved point is what “lazy” actually defers. Module imports may be postponed while interpreter or WebAssembly initialization still occurs during page load. Browser-specific WebAssembly performance, retained memory after a single Python call, and repeat-visit caching can also change the cost comparison. The evaluation should compare transferred bytes, main-thread blocking, time to first Python response, and post-use heap size under otherwise identical pages.
Does PyScript lazy loading defer interpreter startup as well as module imports, or only the imports? Which measurements should determine whether worker execution and extension trimming are worthwhile for a low-traffic page?