Replies: 1 comment
-
|
SolidJS's compilation strategy is designed around producing maximum runtime performance. Creating compiled templates at module initialization time ( 1. Minimizing Runtime Overhead in Hot PathsBy instantiating the template element eager-loaded at the module level, the template DOM structure is parsed by the browser exactly once when the file is loaded. When the component function renders, it only executes If templates were compiled lazily using 2. Eager Parsing is LightweightCreating a template fragment wrapper ( 3. Idiomatic Solution: Code SplittingFor large applications where components like admin panels or dialogs are rarely accessed, the correct way to defer template initialization and reduce bundle size is Code Splitting. Using Solid's native import { lazy } from "solid-js";
// The entire module containing the template is deferred until render
const LazyAdminDashboard = lazy(() => import("./AdminDashboard")); |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I noticed that Solid currently creates compiled templates at module initialization time:
This means every template is created as soon as the module is loaded, even if some components are never rendered.
For large applications, there may be many components that are rarely used (admin pages, dialogs, feature-gated views, etc.), but their templates are still parsed and stored upfront.
Would it make sense to consider lazy template initialization, for example:
With this approach:
I am curious whether this has been evaluated before, and if there are performance tradeoffs or implementation details that make the current eager initialization preferable.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions