Live data from Hacker News

Astro: Ship Less JavaScript

astro.build

131–140 of 171 posts

Re: Astro: Ship Less JavaScript

#131
I'm doing something similar because I was disappointed by the output of current static generators: everything gets prerendered to static markup, runtime JS only augments UX.

In my case, the key breakthrough was reducing everything to arbitrary constrainted emitters with a topological sort.

--

The build uses a GraphQL database to store the results (Prisma/Postgresql because it's great with Typescript).

The whole site is defined by arbitrary Data Sources that read from 0+ other sources and write 1+ unit of data in the database. A source can do anything, the only constant is it must define at least one thing in the database.

For example:

- list of files generated by the webpack build of a specific runtime js

- JSON version of a specific page

- http response to serve when a specific url is requested

---

A topological sort uses the constraints to deduce in which order to render data, for example:

- a page showing the 5 most recent articles can't be rendered before the articles themselves

- the french translation of an article cannot be rendered before the settings of the french website are defined

---

This way, a specific page (or type of pages, or even every page of a site variant) can explicit state it needs a specific js runtime, and the build knows to bundle it before any page that needs it.

Something like a cookie banner would be used by every page whereas a 3d model viewer webcomponent would only be used in specific pages.

---

You end up with a static site as consequence of rendering the "http response to serve when X page is requested" sources, which in turn called all the other sources it required.

The resulting database could even be available in production for dynamic pages that cannot be pre-rendered.

Re: Astro: Ship Less JavaScript

#132

I get it, I’m glad it exists, it’s Neat, and congrats, but it’s also amusing to me that we’ve reached the point of JS tooling where we’re making frameworks to deal with frameworks, build tool frameworks a few levels deep, etc. It just seems like so much…stuff. And now we have stuff to help us use less stuff, but it’s still stuff in itself. Nothing is stopping anyone from opening notepad and writing HTML with inline s…

I felt this way when approaching my personal site. I was falling into the Gatsby trap and then realized all I needed were HTML, CSS, and a few JavaScript files. I think you see over-engineered solutions as a result of career driven development and the hype around these libraries/frameworks on forums/social media.

Problems start when you need to change the HTML structure, the CSS file name, or having a paginated list of your blog. If you do publish a lot, you'll need some sort of CMS.

These frameworks/libraries are trying to replace WordPress, because WordPress is also a mess to work with.

Re: Astro: Ship Less JavaScript

#133
post #2

:wave: Hey everyone, one of the Astro creators here! Happy to talk Astro or answer any questions you have about what we're building. Our README has a bunch more info that we couldn't fit into the release post: https://github.com/snowpackjs/astro

After reading the front page, I'm a little confused. How do you go from "compose your website using UI components from your favorite JavaScript web framework" to "a fully static website with all JavaScript removed from the final page" without losing functionality provided by those components? What's the purpose of using components without JavaScript?

Re: Astro: Ship Less JavaScript

#134

I'm doing something similar because I was disappointed by the output of current static generators: everything gets prerendered to static markup, runtime JS only augments UX. In my case, the key breakthrough was reducing everything to arbitrary constrainted emitters with a topological sort. -- The build uses a GraphQL database to store the results (Prisma/Postgresql because it's great with Typescript). The whole site…

How does your solution compare to Gatsby?

Re: Astro: Ship Less JavaScript

#135

Earlier quoted context omitted.

In your argument, you could replace HTML/CSS with Assembler and JS/React/whatever with C and everything that came after. The productivity gained from these Tools is worth it, even if some use cases could be solved without it.

That's not really fair. A lot of static sites simply don't need JS at all but they're built with it because it's deemed "best practice". My latest website, for example, has zero Javascript in it. So much content is published in Github READMEs (typically markdown) and while Github itself will have Javascript elements, it does demonstrate that you don't need Javascript heavy sites to publish content. I honestly think h…

You can use NextJS to build a fully static website with no JavaScript at the initial loading. There are tons of libraries (I think around 300Mb) to compile your site, but if you do optimizations right, the final website should be as lightweight as you expect it to be.

What you get? Routing, instant refresh, image optimization, and code optimization (your CSS could be smaller if you minify it).

Re: Astro: Ship Less JavaScript

#136
post #133
post #2

:wave: Hey everyone, one of the Astro creators here! Happy to talk Astro or answer any questions you have about what we're building. Our README has a bunch more info that we couldn't fit into the release post: https://github.com/snowpackjs/astro

After reading the front page, I'm a little confused. How do you go from "compose your website using UI components from your favorite JavaScript web framework" to "a fully static website with all JavaScript removed from the final page" without losing functionality provided by those components? What's the purpose of using components without JavaScript?

I don’t use this, but I do something similar for my personal blog.

JSX (and components) is possibly the nicest templating language I’ve ever used. The problem with almost all others is that they are based on strings, so you lose type-safety (and more importantly completions) for the template parameters.

However, the current ecosystem makes it really hard to use JSX for just templating. There are libraries that do exactly that, but you end up wanting compatibility with React, because there are a ton of pre-made components that basically output only HTML (for my use case, react-fontawesome), which you miss out on by using a different library.

Re: Astro: Ship Less JavaScript

#137

I get it, I’m glad it exists, it’s Neat, and congrats, but it’s also amusing to me that we’ve reached the point of JS tooling where we’re making frameworks to deal with frameworks, build tool frameworks a few levels deep, etc. It just seems like so much…stuff. And now we have stuff to help us use less stuff, but it’s still stuff in itself. Nothing is stopping anyone from opening notepad and writing HTML with inline s…

Not everyone is building single page static html sites.

I think the weird weighting goes in the other direction though, more people are over-encumbered with tools they didn't need.

Re: Astro: Ship Less JavaScript

#138
post #2

:wave: Hey everyone, one of the Astro creators here! Happy to talk Astro or answer any questions you have about what we're building. Our README has a bunch more info that we couldn't fit into the release post: https://github.com/snowpackjs/astro

Hello,

I get that you're trying to make websites faster, and it seems like you have some amazing technology, but I have to tell you in all honesty that you have a 1.5 Mb PNG on the linked page. If you want to optimize a website, then (as I'm sure you know) optimizing the images is about the first thing you need to do.

With minimum effort and without apparent loss of quality I could reduce that image to a 0.4 Mb PNG (by uploading to https://imagecompressor.com/), if I'd be willing to change to JPG you can even get it down to 0.2 Mb (https://photoshop.adobe.com/compress).

That's a significant improvement that will really reduce page load times. For me, personally, I would really want to address this if you are positioning yourselves in the website optimization space. Cheers!

Re: Astro: Ship Less JavaScript

#139

I get it, I’m glad it exists, it’s Neat, and congrats, but it’s also amusing to me that we’ve reached the point of JS tooling where we’re making frameworks to deal with frameworks, build tool frameworks a few levels deep, etc. It just seems like so much…stuff. And now we have stuff to help us use less stuff, but it’s still stuff in itself. Nothing is stopping anyone from opening notepad and writing HTML with inline s…

I felt this way when approaching my personal site. I was falling into the Gatsby trap and then realized all I needed were HTML, CSS, and a few JavaScript files. I think you see over-engineered solutions as a result of career driven development and the hype around these libraries/frameworks on forums/social media.

I'm also making my blog in plain html/css/js with the goal of making it as minimal as possible - in fact the JS wouldn't exist if it wasn't for the fact that it includes some running code examples about demoscene stuff.

Except for my procrastination, it's a real pleasure to write this way, no frameworks, no libraries, no build systems with 10k dependencies, no preprocessors for content - just write plain HTML and be done with it, it's always forward compatible, you always have all HTML features and don't have to worry about some preprocessors capability... If I ever have a genuine need for some kind of build process, it will be a self contained script, I'm fed up with the fatigue of the churn of the web tooling world - i'll stuck to a script that will still run in 10 years.

I did make one choice to alleviate the tediousness of writing tags: 'white-space: pre-wrap', which allows you to avoid html tags for basic stuff like paragraphs. Also using fixed width font and ch units since it's mostly a coding blog so this fits well and allows ascii diagrams without extra work... authoring feels like mostly writing an old skool text file with some nice HTML/CSS upgrades.

Re: Astro: Ship Less JavaScript

#140

I get it, I’m glad it exists, it’s Neat, and congrats, but it’s also amusing to me that we’ve reached the point of JS tooling where we’re making frameworks to deal with frameworks, build tool frameworks a few levels deep, etc. It just seems like so much…stuff. And now we have stuff to help us use less stuff, but it’s still stuff in itself. Nothing is stopping anyone from opening notepad and writing HTML with inline s…

In your argument, you could replace HTML/CSS with Assembler and JS/React/whatever with C and everything that came after. The productivity gained from these Tools is worth it, even if some use cases could be solved without it.

If by "productivity" you mean "short term financial gain through leveraging the influx of cheap labour produced by codemonkey farms", then yeah, sure.
Post reply on HN