As I mentioned before, Astra ships zero JavaScript by default. So it uses server side rendering or user service rendering to render these components on the page. And it does that by stripping the all the Javas using the rendering the page on the on the at build time and stripping all the JavaScript away from the page and only shipping you back the markup so that you can, you know, use that with your styles to present that data to the user.
And there are areas where you as I mentioned before, it supports partial hydration. So there are areas where you will need some interactivity. And it uses that by only providing or only loading what's needed for the client at that particular time. So each specific component has a maybe has a certain set of JavaScript functionality. And these include examples like an image carousel or an auto complete search bar or even a mobile sidebar. These are things that were rendered on the client. You still want to have some JavaScript there to, like I said, kind of enhance that experience.
And as I mentioned before, the islands architecture is the idea of using partial hydration to build entire websites. And this is an alternative to the common process of building a website, like a plea in JavaScript and shipping that entire bundle to the user, whether this be a single bundle or maybe a few lazy loaded bundles. But we still get those components loaded individually for the website or maybe a small web application itself. And all these things are loaded in isolation, in other words that they aren't connected to each other in any way so they don't have any dependencies on what's needed to be loaded for those.
So looking at an example page, we have some distinct areas here. We could have a header page where the header is loaded independently on its own island. A navigation bar on the side that may have its own subcomponents there in the main area to display content for the page. And as I mentioned before, all these things are considered islands and isolated and loaded independently from each other.
So this islands architecture or the components in the islands architecture also make use of these different directives. And these are directives that when loaded used on the components, they can tell you when the component is low or when the page is loaded to load the component. When the component is actually visible on the page to not load the Javascript until that component is there. Or if the user is browsing the page and they are idle, then to load those components. So definitely making use of deferring that as far as possible for showing that to the or loading that JavaScript for the user.
So what does this mean in terms of the BYO JS that I've been talking about mentioning during this talk? So BYO JS is bring your own JavaScript framework, included there. And Astro does this through integrations. So Astro is different that you can bring your existing knowledge of your framework of choice and Astro knows how to. Integrate with those web frameworks and render those components on the page statically. And add interactivity to those components later when you need on the client, so you get a little bit of the best of both worlds.
Astro supports just about all the commonly used frameworks that support components out there, such as React, Vue, Svelte, Solid, and more. There are more that I just listed here. They also have APIs that would allow you to potentially integrate any JavaScript framework into an Astro application. You can learn more about the Astro project at astro.build. You can read more through the docs, learn more about the integrations and see how it can help you build websites faster there. So definitely check that out.
So to recap, I talked about the history and evolution of building web applications, using service or traditional service side, client side, and applications and frameworks. Talk about the next wave of web frameworks, some of that are out there today, such as using the Jamstack and other tools in that space. And talked about the Astro project.
Comments