<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Georges Gomes</title>
    <description>The latest articles on Forem by Georges Gomes (@georges_gomes).</description>
    <link>https://forem.com/georges_gomes</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F189050%2F733db1dc-044e-4174-83f2-afad483bb64b.png</url>
      <title>Forem: Georges Gomes</title>
      <link>https://forem.com/georges_gomes</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/georges_gomes"/>
    <language>en</language>
    <item>
      <title>Our experience with Astro</title>
      <dc:creator>Georges Gomes</dc:creator>
      <pubDate>Fri, 09 Jul 2021 17:10:22 +0000</pubDate>
      <link>https://forem.com/divriots/our-experience-with-astro-1hk8</link>
      <guid>https://forem.com/divriots/our-experience-with-astro-1hk8</guid>
      <description>&lt;p&gt;We built &lt;a href="https://divRIOTS.com/" rel="noopener noreferrer"&gt;divRIOTS.com&lt;/a&gt; with &lt;a href="https://astro.build" rel="noopener noreferrer"&gt;Astro&lt;/a&gt;.&lt;br&gt;
"Here we go, another framework is out and another dude is making a website and blogging about it"&lt;/p&gt;

&lt;p&gt;Let's see if we can make this interesting. 😉&lt;/p&gt;
&lt;h2&gt;
  
  
  What is Astro?
&lt;/h2&gt;

&lt;p&gt;If you already know &lt;a href="https://astro.build" rel="noopener noreferrer"&gt;Astro&lt;/a&gt;, you can skip to the next chapter.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://astro.build" rel="noopener noreferrer"&gt;Astro&lt;/a&gt; is a Static Site Generator (SSG). Build your pages in &lt;code&gt;.astro&lt;/code&gt; files (very close to HTML/JSX) and sparkle them with React/Vue/Preact/Svelte components. It deals with file-based routing and templates neutrally. Bring your component framework. &lt;cite&gt;In my words&lt;/cite&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;There is more to it. See &lt;a href="https://astro.build/blog/introducing-astro" rel="noopener noreferrer"&gt;Astro's introduction blog post&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And if you have time, there is a &lt;a href="https://www.learnwithjason.dev/ship-less-javascript-with-astro" rel="noopener noreferrer"&gt;90min video and Transcript&lt;/a&gt; about it.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why we chose Astro
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Not because it's the new/latest shiny framework 😀&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I shared my thought in April when I first saw &lt;a href="https://astro.build" rel="noopener noreferrer"&gt;Astro&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1380801812656226304-686" src="https://platform.twitter.com/embed/Tweet.html?id=1380801812656226304"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1380801812656226304-686');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1380801812656226304&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;When it was time to develop the new &lt;a href="https://divRIOTS.com/" rel="noopener noreferrer"&gt;divRIOTS.com&lt;/a&gt; website, we searched for the best option.&lt;/p&gt;

&lt;p&gt;Our requirements were:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Simple&lt;/strong&gt; - It's not going to be a massive site.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Runs on JavaScript&lt;/strong&gt; - Ecosystem we know well.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Generate 100% static HTML&lt;/strong&gt; - Good performance, good SEO.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;File-based routing&lt;/strong&gt; - Very convenient&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Allow component-driven development&lt;/strong&gt; - That's how we like to build&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Markdown support&lt;/strong&gt; - For the blog posts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are &lt;a href="https://jamstack.org/generators/" rel="noopener noreferrer"&gt;many static site generators&lt;/a&gt;.&lt;br&gt;
But, believe it or not, there aren't many options matching our requirements.&lt;/p&gt;

&lt;p&gt;Most component-driven options will come with some relatively heavy JavaScript&lt;br&gt;
payloads for &lt;a href="https://en.wikipedia.org/wiki/Hydration_(web_development)" rel="noopener noreferrer"&gt;hydration&lt;/a&gt;, even if the content is 100% static.&lt;/p&gt;

&lt;p&gt;On the other end, truly JavaScript-less SSG will use template-engine like &lt;a href="https://mozilla.github.io/nunjucks/" rel="noopener noreferrer"&gt;Nunjucks&lt;/a&gt; or &lt;a href="https://shopify.github.io/liquid/" rel="noopener noreferrer"&gt;Liquid&lt;/a&gt;. They are amazing options but it's another language and another paradigm. Not component-driven.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;We just wanted a good Static Site Generator with a JavaScript Developper Experience and 100% HTML output by default. And &lt;a href="https://astro.build" rel="noopener noreferrer"&gt;Astro&lt;/a&gt; is precisely that.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  Pure Astro
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://divRIOTS.com/" rel="noopener noreferrer"&gt;divRIOTS.com&lt;/a&gt; is built in 100% &lt;a href="https://astro.build" rel="noopener noreferrer"&gt;Astro&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;No &lt;a href="https://reactjs.org" rel="noopener noreferrer"&gt;React&lt;/a&gt;, No &lt;a href="https://vuejs.org" rel="noopener noreferrer"&gt;Vue&lt;/a&gt;, No &lt;a href="https://svelte.dev" rel="noopener noreferrer"&gt;Svelte&lt;/a&gt;, None of the &lt;a href="https://github.com/snowpackjs/astro#-partial-hydration" rel="noopener noreferrer"&gt;partial hydration&lt;/a&gt; or &lt;a href="https://jasonformat.com/islands-architecture/" rel="noopener noreferrer"&gt;islands&lt;/a&gt; capabilities of &lt;a href="https://astro.build" rel="noopener noreferrer"&gt;Astro&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Just &lt;code&gt;.astro&lt;/code&gt; files.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You don't need to use the cutting-edge hydration capabilities of &lt;a href="https://astro.build" rel="noopener noreferrer"&gt;Astro&lt;/a&gt; to already benefit from it.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://astro.build" rel="noopener noreferrer"&gt;Astro&lt;/a&gt; comes with an elegant component model and a solid CSS pipeline with Scoped CSS, CSS Modules, and Sass support.&lt;/p&gt;

&lt;p&gt;OUT-OF-THE-BOX.&lt;/p&gt;
&lt;h2&gt;
  
  
  Underrated feature
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://astro.build" rel="noopener noreferrer"&gt;Astro&lt;/a&gt;'s CSS Bundling is probably its most underrated feature. It never makes it to the headline but it's by far my favorite!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In &lt;a href="https://astro.build" rel="noopener noreferrer"&gt;Astro&lt;/a&gt;, you just layout &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; tags in your astro components where you need them and add lists of &lt;code&gt;&amp;lt;link ref="stylesheet"&amp;gt;&lt;/code&gt; in your &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For example, &lt;a href="https://divRIOTS.com/" rel="noopener noreferrer"&gt;divRIOTS.com&lt;/a&gt; uses 2 global css in &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; in the most idiomatic way.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"/css/reset.css"&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"/css/global.css"&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;None of these &lt;code&gt;.css&lt;/code&gt; files are minified and calling them separately doesn't provide the best performance result.&lt;/p&gt;

&lt;p&gt;But when built for production with &lt;code&gt;astro build&lt;/code&gt;, &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; tags and &lt;code&gt;&amp;lt;link ref="stylesheet"&amp;gt;&lt;/code&gt; are minified and bundled automatically.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If a style only appears on one route, it’s only loaded for that route. (&lt;code&gt;/_astro/[page]-[hash].css&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;If a style appears on multiple routes, it’s deduplicated into a (&lt;code&gt;\_astro/common-[hash].css&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In production, pages have:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"/_astro/common-[hash].css"&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"/_astro/mypage-[hash].css"&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;/_astro/common-[hash].css&lt;/code&gt; is the same on every page. It's cached and not re-downloaded during navigation on the site. It's hard to have a better result.&lt;/p&gt;

&lt;p&gt;This means that I can write styles the way it makes sense for readability and maintenance and let &lt;code&gt;astro build&lt;/code&gt; take care of best performance.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I don't know any static site generator capable of doing [pure] CSS Bundling and minification so seamlessly.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;More details in &lt;a href="https://github.com/snowpackjs/astro/blob/main/docs/styling.md#-bundling" rel="noopener noreferrer"&gt;Astro's Styling Guide #bundling&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Performance results
&lt;/h2&gt;

&lt;p&gt;The output is 100% optimized HTML/CSS. It's hard to be slow 😀&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg0suko3raqa4kyt3rpcl.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg0suko3raqa4kyt3rpcl.jpg" alt="Mobile performance results (98)"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Finc12nwi92x87vpy684a.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Finc12nwi92x87vpy684a.jpg" alt="Desktop performance results (100)"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What's missing in Astro
&lt;/h2&gt;

&lt;p&gt;In my humble opinion, not much. &lt;a href="https://divRIOTS.com/" rel="noopener noreferrer"&gt;divRIOTS.com&lt;/a&gt; is proof of that.&lt;/p&gt;

&lt;p&gt;But here is my wish list:&lt;/p&gt;

&lt;h3&gt;
  
  
  JavaScript processing
&lt;/h3&gt;

&lt;p&gt;Like &lt;a href="https://astro.build" rel="noopener noreferrer"&gt;Astro&lt;/a&gt;'s CSS Bundling, I would like my &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tags transpiled, bundled, chunked, and minified in the best possible way.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Transpiled : I can write ES202X code and get a more compatible output.&lt;/li&gt;
&lt;li&gt;Bundled : I can import bare modules from &lt;code&gt;node_modules&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Chuncked : If modules are used on many pages, move them into a single &lt;code&gt;common-chunk.js&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Minified : Everybody wants small JavaScript - always.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With this, I don't need a &lt;a href="https://webpack.js.org/" rel="noopener noreferrer"&gt;webpack&lt;/a&gt; or &lt;a href="https://gulpjs.com/" rel="noopener noreferrer"&gt;gulp&lt;/a&gt; configuration on top of &lt;a href="https://astro.build" rel="noopener noreferrer"&gt;Astro&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/snowpackjs/astro/issues/370" rel="noopener noreferrer"&gt;GitHub issue #370&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Image processing
&lt;/h3&gt;

&lt;p&gt;Like JavaScript, image optimization is another fairly complex build process to add on top of static site generators. Having out-of-the-box support would help get maximum performance with minimal effort.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/snowpackjs/astro/issues/492" rel="noopener noreferrer"&gt;GitHub Issue #492&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  "Permalink” for certain pages
&lt;/h3&gt;

&lt;p&gt;Today all pages are generated as &lt;code&gt;/slug/index.html&lt;/code&gt;, but some pages need to be generated as &lt;code&gt;/slug.html&lt;/code&gt; instead. Like &lt;code&gt;/404.html&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/snowpackjs/astro/issues/465" rel="noopener noreferrer"&gt;GitHub Issue #465&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Closing thoughts
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://astro.build" rel="noopener noreferrer"&gt;Astro&lt;/a&gt; is more than a SSG&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;As described in &lt;a href="https://twitter.com/georges_gomes/status/1380801812656226304" rel="noopener noreferrer"&gt;my tweet about Astro&lt;/a&gt;, another compelling feature of &lt;a href="https://astro.build" rel="noopener noreferrer"&gt;Astro&lt;/a&gt; is his neutrality to frameworks.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://astro.build" rel="noopener noreferrer"&gt;Astro&lt;/a&gt; takes care of routing, layouts, data management and SSR infrastructure and you can bring your components from any other framework (currently &lt;a href="https://reactjs.org" rel="noopener noreferrer"&gt;React&lt;/a&gt;, &lt;a href="https://vuejs.org" rel="noopener noreferrer"&gt;Vue3&lt;/a&gt;, &lt;a href="https://preactjs.com" rel="noopener noreferrer"&gt;Preact&lt;/a&gt;, and &lt;a href="https://svelte.dev" rel="noopener noreferrer"&gt;Svelte&lt;/a&gt;) but still keep zero JavaScript runtime on the output if you want.&lt;/p&gt;

&lt;p&gt;It makes your site last longer as component frameworks come and go. It also makes your component last longer as you don't need to migrate them from one framework to another. Just use them as long as you want.&lt;/p&gt;

&lt;p&gt;I called &lt;a href="https://astro.build" rel="noopener noreferrer"&gt;Astro&lt;/a&gt; an "Agnostic Meta-Framework". And I think we will see other solutions emerge in this space because it makes a lot of sense to decouple the meta-frameworks from the rendering libraries.&lt;/p&gt;

&lt;h2&gt;
  
  
  Another Astro website is coming up
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://backlight.dev" rel="noopener noreferrer"&gt;Backlight.dev&lt;/a&gt;, our upcoming product to build and manage Design Systems on the code-side, will be revealed soon.&lt;/p&gt;

&lt;p&gt;The full landing is also made in &lt;a href="https://astro.build" rel="noopener noreferrer"&gt;Astro&lt;/a&gt; but taking it to a whole new level 🚀&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Stay tuned!&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>astro</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
