1

Why does RemixJS use Web Containers?

 2 years ago
source link: https://blog.bitsrc.io/why-does-remixjs-use-web-containers-604edfaaca0a
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Why does RemixJS use Web Containers?

5 Reasons Why Remix uses Web Containers

0*paLFrzyAu2bTmwqr.jpg

The Remix is an open-source framework built on React. Remix supports server-side renderings and creates both front end and back-end through a single application. Therefore, some developers are used to considering Remix as a full-stack development framework.

I used Remix for several projects, and one of the interesting things I found about Remix was that it uses web containers. So, in this article, I will discuss why Remix uses web containers to give you a better understanding.

What are Web Containers?

A web container, also called a servlet container, is a part of a web server that interacts with servlets. A web container manages servlet lifecycles, mapping URLs to specific servlets. It ensures that the URL requester has the appropriate access privileges. And also generates servlet instances, loads and unloads servlets, manages request and response objects, and handles other servlet-related operations.

Web containers are also capable of managing sessions. This is the procedure for generating and deleting web pages in response to user requests. Also, web containers are in charge of navigation control, which involves creating and destroying web pages as users travel across a website.

Following is a list of open source and commercial web containers:

Open source web containers:

  • Apache Tomcat
  • GlassFish
  • Jetty
  • Enhydra

Commercial web containers:

  • Orion application server
  • iPlanet webserver

Since now you understand what web containers are and their capabilities, let's see why Remix uses web containers.

Why does Remix use Web Containers?

1. Execution Speed

The first thing is speed. Containers are lightweights, and they do not have any operating system. This means web containers help to start fast execution for applications. Remix achieves excellent accuracy on web containers due to the above reason.

2. Progressive enhancement through web containers

The built-in solution for managing forms is a fantastic illustration of the progressive enhancement of Remix. It lets you use forms without any interruption, even when JavaScript code is not available. Although the concept of progressive enhancement has been known for a long time, only a few other frameworks include this type of best-practice behavior.

Remix has both read and write properties. With the progressive enhancement, Remix enables the data layer to perform with or without JavaScript. When Remix adds JavaScript, it speeds up the user experience in page transitions by :

  1. Not downloading and evaluating JavaScript and CSS assets.
  2. Obtaining data only for the areas of the layout that changes.

Remix can give APIs to the developer to enhance the UX on page transitions smoother with JavaScript on the page by :

  1. For example, replacing the browser's spinning favicon with a more appealing pending UI.
  2. Providing an upbeat UI On data actions

Since data mutation is built into Remix, it knows when to re-fetch data that may have changed due to the mutation, ensuring that different areas of your website remain in sync.

The goal is not to make the app run without JavaScript, as it is to keep the client-server relationship simple. Web containers come with a virtualized TCP network stack mapped to your browser's ServiceWorker API, allowing you to quickly deploy live servers that keep working even when you're offline. Server answers have shorter latency than localhost. It assures progressive enhancement for your app.

3. Saves resources

Remix with web containers helps enhance application development productivity by using full potential browser performance. You can always get a lightweight web application when you use web containers. And it will be an added advantage for Remix applications. With less demand on the server when using web containers, we can devote more resources to Remix apps. These resource savings become critical when you're attempting to scale your app.

4. Web containers can be more secure

The concept of "namespaces" is used to construct containers. Also, it can be seen in Remix applications as well. This concept is used to keep your Remix apps secure, and data is only shared across apps if you want it to be. Additionally, unlike traditional dedicated servers, each container is typically configured to deliver a single service, which might help limit damage in the event of an attack.

The way it handles CSS is an excellent example of this. The Remix adds the <link> tag for a stylesheet dedicated to a specific component and leaves the browser to handle the rest. As a result, you'll be able to limit the scope of the styles and have access to CSS's cascade feature, including smaller, loaded on-demand stylesheets.

5. Web containers are easy to debug in the browser

Web containers allow developers to debug their applications in the browser quickly, which applies to Remix. So, you can use Chrome Dev Tools to debug your Remix applications. What you have to do is to put debugger where you need to debug.

Conclusion

As discussed in the article, Remix always has a better advantage when combined with web containers. This is because web containers help Remix applications manage the life cycle efficiently, enhance productivity and utilize the browsers to their full potential.

I hope you have found this helpful. Thank you for reading.

Build composable web applications

Don’t build web monoliths. Use Bit to create and compose decoupled software components — in your favourite frameworks like React or Node. Build scalable and modular applications with a powerful and enjoyable dev experience.

Bring your team to Bit Cloud to host and collaborate on components together, and speed up, scale, and standardize development as a team. Try composable frontends with a Design System or Micro Frontends, or explore the composable backend with serverside components.

Give it a try →

0*YpHFTWA6pG6xcuhs.gif

Learn more


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK