Skip to content

Latest commit

 

History

History
79 lines (46 loc) · 8.69 KB

primer.md

File metadata and controls

79 lines (46 loc) · 8.69 KB

Rendering Patterns

  • Server-side rendering: In this pattern, the server generates the HTML for a page and sends it to the client's browser. This allows for faster initial page load times, but can result in slower subsequent interactions.

  • Client-side rendering: In this pattern, the initial HTML for a page is sent from the server, but subsequent updates to the page are handled by the client's browser. This allows for faster interactions, but can result in slower initial page load times.

  • Isomorphic rendering: In this pattern, the same code is used to generate the initial HTML on the server and to handle subsequent updates on the client's browser. This allows for a balance of faster initial page load times and faster subsequent interactions.

  • Static rendering: In this pattern, the entire HTML for a page is generated at build time and is served as a static file. This allows for the fastest initial page load times, but does not allow for any dynamic updates to the page.

  • Progressive rendering: In this pattern, the initial HTML for a page is sent from the server, but only a portion of the page is initially rendered. Subsequent updates to the page are then progressively rendered as needed. This allows for faster initial page load times and faster subsequent interactions.

Server Side Rendering

Server-side rendering involves generating the HTML for a UI on the server and sending it to the client, where it is rendered in the browser. Some of the pros of this approach include:

  • Improved initial load time: By generating the HTML on the server, the browser can start rendering the page immediately, without needing to wait for the data to be fetched from the server. This can improve the initial load time of the page and provide a better user experience.

  • Better SEO: By generating the HTML on the server, search engines can crawl and index the page more easily, improving the visibility of the site in search results.

  • Better security: By generating the HTML on the server, sensitive information can be kept out of the client's web browser, improving the security of the application.

However, server-side rendering can also have some drawbacks, including:

  • Additional complexity: Server-side rendering can add additional complexity to an application, as it requires the server to generate the HTML and the client to render it. This can make the development process more challenging, and it can also require additional infrastructure and resources.

  • Performance limitations: Server-side rendering can be slower than other rendering patterns, as it requires the server to generate the HTML and the client to render it. This can make the application less performant, particularly for complex or heavily-loaded pages.

  • Limited interactivity: Server-side rendering can be less interactive than other rendering patterns, as the HTML is generated on the server and sent to the client as a static document. This can limit the ability to provide real-time updates and dynamic interactions within the UI.

Use Cases for Server Side Rendering: Server-side rendering can be a good choice for applications that have a strong emphasis on initial load time and SEO, such as blogs and news sites. It can also be a good option for applications that require a high level of security, such as e-commerce or financial services sites.

Client Side Rendering

Client-side rendering involves generating the HTML for a UI in the client's web browser. Some of the pros of this approach include:

  • Increased flexibility: By generating the HTML in the client's web browser, the application can be more flexible and dynamic, allowing for real-time updates and interactions within the UI.

  • Improved interactivity: By generating the HTML in the client's web browser, the application can provide a more interactive and engaging user experience, with features such as animations and transitions.

  • Reduced load on the server: By generating the HTML in the client's web browser, the application can reduce the load on the server, as it doesn't need to generate the HTML for each page request. This can be particularly beneficial for applications with high traffic or complex pages.

However, client-side rendering can also have some drawbacks, including:

  • Slower initial load time: By generating the HTML in the client's web browser, the initial load time of the page can be slower, as the browser must first fetch the data and then generate the HTML. This can be a significant disadvantage for applications that require a fast initial load time, such as e-commerce or news sites.

  • Reduced SEO: By generating the HTML in the client's web browser, search engines may have difficulty crawling and indexing the page, as the HTML is not available until the page is fully loaded. This can reduce the visibility of the site in search results.

  • Additional optimization: By generating the HTML in the client's web browser, the application may require additional optimization techniques to ensure good performance

Use Cases Single-page applications (SPAs): SPAs are web applications that are designed to function as a single page, with all the necessary HTML, CSS, and JavaScript being loaded in the initial page load. By using client-side rendering, SPAs can provide a smooth and seamless user experience, with minimal page reloads and fast, responsive interactions.

Applications with heavy real-time data: Applications that require a large amount of real-time data, such as social media, messaging, or collaborative tools, can benefit from client-side rendering. By generating the HTML in the client's web browser, these applications can provide real-time updates and dynamic interactions within the UI, allowing users to see the latest data and collaborate in real time.

Applications with complex or interactive UIs: Applications with complex or interactive UIs, such as games, data visualization tools, or design tools, can benefit from client-side rendering. By generating the HTML in the client's web browser, these applications can provide a more engaging and interactive user experience, with features such as animations, transitions, and responsive interactions.

Factors to figure out optimum rendering strategy

What are the various factors that are incorporated to assess which rendering strategy to go for ?

There are several factors that can be considered when choosing a rendering strategy for a frontend application. Some of the most common factors include:

Performance: Performance is an important consideration when choosing a rendering strategy, as it can have a significant impact on the user experience and the overall success of the application. Different rendering strategies can have different performance characteristics, and it's important to carefully evaluate the trade-offs and benefits of each approach in order to choose the best option for a given application.

Initial load time: The initial load time of a page can be an important factor when choosing a rendering strategy, as it can affect the user experience and the overall performance of the application. Some rendering strategies, such as server-side rendering, can provide faster initial load times, while others, such as client-side rendering, can be slower.

SEO: Search engine optimization (SEO) is an important factor for many applications, as it can affect the visibility of the site in search results and the ability of users to find the site. Different rendering strategies can have different implications for SEO, and it's important to carefully evaluate the trade-offs and benefits of each approach in order to choose the best option for a given application.

Flexibility and interactivity: The flexibility and interactivity of a frontend application can be an important factor when choosing a rendering strategy. Some rendering strategies, such as client-side rendering, can provide a more flexible and interactive user experience, while others, such as server-side rendering, can be less flexible and interactive.

Security: The security of a frontend application can be an important factor when choosing a rendering strategy. Some rendering strategies, such as server-side rendering, can provide better security, as sensitive information can be kept out of the client's web browser, while others, such as client-side rendering, can be less secure.

Development complexity: The development complexity of a frontend application can be an important factor when choosing a rendering strategy. Some rendering strategies, such as server-side rendering, can add additional complexity to the development process, while others, such as client-side rendering, can be simpler and more straightforward.

TODO

  • Module Federation
  • State Management in Module Federation
  • CORS
  • Browser Storage (Pro / Cons / Use Cases)
  • Authentication
  • HTTP