Home Web Front-end CSS Tutorial Rendering Spectrum

Rendering Spectrum

Mar 31, 2025 pm 02:06 PM

Rendering Spectrum

Website rendering is mainly divided into three categories:

  • Client-side Rendering:<div></div> Send to the client and rendered by the JavaScript template.
  • Static Rendering: Pre-render HTML.
  • Server-side Rendering: The server processes the request and generates an HTML response.

These three categories are not mutually exclusive and can be used in mixture. For example:

  • A website can statically pre-render 75% of pages (such as blog posts), while the remaining 25% of pages are responded by the server (such as forums).
  • A website can statically pre-render all pages, but contains some empty ones.<div> ,These<code><div> Contains the client rendered content (for example, a dynamically generated menu based on the logged-in user).<li> A website mainly uses server-side rendering, but has a cache in front of it, making it behave like static rendering.</li> <li> A website can be rendered statically and then "hydrated" into a fully client-side rendered website.</li> <li> A website can mix server-side and static rendering, but has dynamic parts similar to client-side rendering, but actually happens in edge functions, so it ends up being more like server-side rendering.</li> <p> What's unique about Next.js is that it can implement these three rendering methods at the same time. Tim Neutkens mentioned in a recent interview:</p> <blockquote> <p> Next.js allows you to pre-render the page. It uses static site generation (SSG) to create HTML on the server at build time, or to use server-side rendering (SSR). Next.js allows you to use both ways. Unlike most other frameworks, you are not limited to fully statically generated applications. You can have some pages rendered server-side while others are generated statically.</p> <p> In the new version, we can update these statically generated pages without rebuilding the entire application.</p> </blockquote> <p> This flexibility is great! For many websites, it is not practical to use a single rendering method throughout the disk.</p> <p> Client rendering is the most flexible, but the disadvantages are also obvious, such as poor performance, low reliability, heavy equipment burden, unfriendly SEO, etc. Static pre-rendering is the most robust, fast and secure, but has the most limited functionality. Edge functions based on static rendering have begun to open some doors, while server-side rendering classically takes into account both flexibility and speed, and has long dominated.</p> <p> Client rendering also brings the "Single Page Application (SPA)" experience. This feeling of pageless refresh makes the website faster and facilitates page transitions. Gatsby is known for promoting “hydration”, combining the advantages of pre-rendering static content and upgrades to SPA after JavaScript downloads.</p> <p> Ideally, we want a good user experience with the SPA without building it. This is especially worthy of attention when frameworks provide SPA feelings without managing a lot of JavaScript on their own, but there is still <em>some</em> mechanism to manage it.</p> <p> Tom MacWright also explores this issue in its article "If it's not a SPA, what is that?" Some existing alternatives include:</p> <blockquote><p> Turbolinks… <em>What is the least thing you need to do without relying on application matching in order to get a SPA experience?</em></p></blockquote> <p> Turbolinks works similarly: clicking on links, intercepting click events, making Ajax requests for new pages, and JavaScript replacing page content with new content. It's very simple to implement, but it still relies on JavaScript and is not smart enough to reduce data transfers.</p> <blockquote><p> barba.js and instant.page are other ways to solve similar problems.</p></blockquote> <p> Barba focuses on page transition effects. instant.page mainly preloads/pre-renders the page before clicking, so even if the page is refreshed, it feels less noticeable (especially when keeping the drawing). Both are cool, but not a complete replacement for SPA. (Even with keeping the pages drawn, pre-rendered, and lightweight, I think the experience is still not as smooth as the SPA. For example, you'll still see the page loading spinner.)</p> <p> So, is there any other way? There may be some. For example<code><portal></portal> . It may be oversimplified, but the basic idea is: portals are similar to iframes. They can even be visually displayed like an iframe. This means that rendering of the URL in portal has been completed. You can then "elevate" the portal to the active page, and even animate the portal itself when doing this.

    I don't think this is not impossible. I can imagine someone building a Turbolinks-like library based on portals, making it "easy to use" and making the website more like a SPA.

    However, animateing rectangles to specified positions is usually not an ideal effect for page animation transitions. Please refer to Sarah's article "Page Transitions Similar to Native Animation on the Web". That's what people want (at least that possibility). That's why Jeremy joked recently when she said " most single page apps are just huge carousels " that it 's not portals . He also mentioned the navigation transition proposal proposed by Jake a few years ago.

    I like this proposal. It focuses on the needs of users. It also asks why people choose JavaScript frameworks instead of using the features provided by the browser. People choose JavaScript frameworks because browsers do not provide certain features: components such as tabs or accordion; DOM differences; controlling the style of complex form elements; navigation transitions. The problem that the JavaScript framework is solving today should be considered as the R&D department of tomorrow's Web standards. (Instead, I firmly believe that the goal of any good JavaScript framework should be to make itself redundant.)

    So, what is the best rendering method? What suits you is the best, but the following hierarchies may have some general meaning:

    1. Use as much static HTML as possible
    2. Use static HTML-based edge functions to handle dynamic content
    3. Then use the HTML generated by the server
    4. Client rendering is only performed if absolutely necessary

The above is the detailed content of Rendering Spectrum. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1266
29
C# Tutorial
1239
24
Google Fonts   Variable Fonts Google Fonts Variable Fonts Apr 09, 2025 am 10:42 AM

I see Google Fonts rolled out a new design (Tweet). Compared to the last big redesign, this feels much more iterative. I can barely tell the difference

How to Create an Animated Countdown Timer With HTML, CSS and JavaScript How to Create an Animated Countdown Timer With HTML, CSS and JavaScript Apr 11, 2025 am 11:29 AM

Have you ever needed a countdown timer on a project? For something like that, it might be natural to reach for a plugin, but it’s actually a lot more

HTML Data Attributes Guide HTML Data Attributes Guide Apr 11, 2025 am 11:50 AM

Everything you ever wanted to know about data attributes in HTML, CSS, and JavaScript.

A Proof of Concept for Making Sass Faster A Proof of Concept for Making Sass Faster Apr 16, 2025 am 10:38 AM

At the start of a new project, Sass compilation happens in the blink of an eye. This feels great, especially when it’s paired with Browsersync, which reloads

How We Created a Static Site That Generates Tartan Patterns in SVG How We Created a Static Site That Generates Tartan Patterns in SVG Apr 09, 2025 am 11:29 AM

Tartan is a patterned cloth that’s typically associated with Scotland, particularly their fashionable kilts. On tartanify.com, we gathered over 5,000 tartan

How to Build Vue Components in a WordPress Theme How to Build Vue Components in a WordPress Theme Apr 11, 2025 am 11:03 AM

The inline-template directive allows us to build rich Vue components as a progressive enhancement over existing WordPress markup.

PHP is A-OK for Templating PHP is A-OK for Templating Apr 11, 2025 am 11:04 AM

PHP templating often gets a bad rap for facilitating subpar code — but that doesn&#039;t have to be the case. Let’s look at how PHP projects can enforce a basic

A Comparison of Static Form Providers A Comparison of Static Form Providers Apr 16, 2025 am 11:20 AM

Let’s attempt to coin a term here: "Static Form Provider." You bring your HTML

See all articles