SSG, SSR, CSR, ISR... Understanding web rendering strategies to optimize performance and user experience based on your needs.
When a user loads a web page, several rendering strategies can be used depending on performance, interactivity, and server cost requirements. This article details the different approaches, explaining how they work from the initial request to JavaScript execution and the activation of user interactions.
The strategies covered include:
Each strategy is characterized by how the page is served (pre-generated or rendered on the fly), the role of JavaScript in the final output, and how user interactions are managed once the page is loaded.
Principle
Pages are generated at build time and served as-is to users. The server or CDN simply returns a ready-to-use HTML/CSS/JS file.
Technical Process
Advantages
Disadvantages
Principle
The server dynamically generates the HTML page for each request before sending it to the client.
Technical Process
Advantages
Disadvantages
Principle
The server sends a minimal HTML file, and JavaScript builds the interface on the client side.
Technical Process
Advantages
Disadvantages
Principle
An enhanced version of SSG that allows on-the-fly regeneration of static pages without a full site rebuild.
Technical Process
Advantages
Disadvantages
Principle
This strategy handles data fetching on the client side: cached data is displayed immediately, and new data is fetched in the background.
Technical Process
Advantages
Disadvantages
Principle
A combined approach that integrates multiple strategies:
This method maximizes performance by leveraging the advantages of each approach.
You can also combine in the same page SSG with CSR.
The choice of rendering strategy depends on the specific context and requirements of the project. A simple showcase website might rely solely on SSG, while a dynamic SaaS application could benefit from a hybrid rendering approach that combines SSR, ISR, and SWR.
The goal remains to optimize user experience while reducing server load and page load times, ensuring efficient JavaScript execution to activate interactions.
Clear insights to make the right technical decisions, even if you're not a dev.