As mentioned and for what is rendered at the server-side.
Things that can be done without JavaScript:
- Style basic HTML set on the page.
- Predefine sizes on LCP (although even the header is not available SSR).
- Set the scripts to and things to preload.
Most features depend on JavaScript to transform the DOM and hydrate it.
- Load and prioritize resources that are not in head.html.
- Initially hide the body.
- Parse DOM.
- Compile rendering blocking styles and JavaScript.
- Load header.plain.html.
- Load other non-eager components.
The only server-side injection available is by head.html.
- Client-side Hydration DOM transformation "decoration."
- Manual focus on FCP and LCP.
- Queue and block each resource before loading and rendering next.
- Performance by avoiding visible rendering before loading required.
- Decoration by feature.
- Manually defining priority of required.
- Eager and deferred.
- Semantical content used as component functional content (metadata) among others.
- Setup SampleRun.
- Eager loading
- decorateTemplateAndTheme (Required once, add classes to body).
- Load external header, add CSS variables using metadata (required to avoid CLS and must be defined used styles.css).
- decorateMain (Required once, but need to run always that a new DOM is loaded or added) includes:
- decorate buttons, icons, blocks, Section, Images, grid.
- If desktop loads fonts.
- Lazy and delayed
- Load blocks (by order of appearance)
- Load footer and decorate it manually
- Load fonts
- Load lazy styles
- Observe for delayed, etc.
An example of a block
export default async function decorate(block) {
// add feature to a element (block)
// Eg add events transform it etc.
}
Here are some examples: Example HEADER
- Simple
- Functional approach good for testing
- JavaScript modules
- Enforce LCP
- Performance monitoring using RUM
- Blocks need to be executed manually in every element
- Any new DOM needs to be decorated manually
- Limited reusability of a "component"
- Low opinionated allows free-style coding / no code best practices enforcing
- No clear life cycle of a block
- Uses semantical data as parameters and passing options