Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

No, I don't really like react, and it's probably bound to have the same problem as Nuxt. The issue is that the site, at least with Nuxt, is pre-rendered to HTML, right, but it still needs to have Vue (because usually you would want to then use it to then refresh the content). The thing is this, apart from having to have Vue and a bunch of JS, it also adds your posts inline to the script (because Vue can't just extract the content from the DOM (well, it technically can, but this would be a mess for varying reasons). This is a bunch of bloat since I want the site to be static to be fast. You can delete the script tags after the rendering (using something like cheerio), but this gets rid of all your scripts (which I still need some small ones to for example, lazy load images). I could keep them separate and then insert them back in but then I lose the pleasure of using Vue. It's kind of impossible to solve as far as I see.


Ok I see what you're saying but I don't see why it's a big deal. The JavaScript is non-blocking right? So the static page is still displayed just as quickly. Gatsby does code splitting so the bundles are pretty small and keep in mind it takes advantage of preload/prefetch. Using JS to render a new page is going to be faster than loading the entire static page. Maybe you should try testing out real world performance vs something like Jekyll.


Technically, yes it's non-blocking, that's not the problem. For something like, for example, a store front, I agree, these framework renderers are great because/when:

- You have little data that needs to be pre-loaded (e.g. item name, price, description, thumbnail, etc). - If you do have a lot of data, then your website is of the type that users revisit a lot (e.g. a documentation site). - The data is modular (it's not one chunk of data) and can benefit from using a framework to organize it. - Very little content changes from page to page (in a store front, the majority of the layout is re-used). - There's a lot of DOM manipulation you want to do (e.g. checkout, cart, etc)

This is not true of content heavy blogs:

- It's a lot of data which must at a minimum be duplicated twice. - The data is not modular. In one markdown file you have to process the text, images, videos, embeds, etc., all at once. So, for example, you can't take advantage of your framework to generate image tags. - There's almost zero DOM manipulation needed (at most I might have a portfolio page which needs some js, a lazy-load script, and some share buttons). - A lot of content changes from page to page (it overshadows any content they might have in common). - The content is not exactly of the type users would revisit often.

With Nuxt (again don't know with Gatsby, and I think they're working in Nuxt to fix this), you also have to jump through hoops to pre-convert your markdown to html because otherwise you're converting on the client side. Found this out when I looked at the bundles and there were a bunch of emojis in it, turns out it was my markdown converter getting imported into the bundle.

Now, let's suppose this wasn't that difficult, there was some function were you could pre-convert this data and it wasn't including the libraries to do it in the bundle.

Except this is THE pain point of SSGs for blogs. The majority of the problems are here and you would essentially end up writing a static generator inside this function (when I realized this I gave up on Nuxt and similar framework renderers). I would have gained very little for that headache, and how big I would be willing to have the bundle size is a LOT smaller.

And while, yes, bundle sizes are usually small and don't matter for the cases I outlined in the beginning, this is not true, like I said, of a content heavy blog. I don't have a nice a proper benchmark, but I do have some notes from when I tried nuxt. These are the sizes of a single test index page (plain text + a couple lines of css for basic styling) and the full loading times with unthrottled and fully throttled (though this is a bit deceiving* ):

Nuxt w/o Content ~170kb - 250ms - 7.8s

Nuxt w/ 10 Blog Posts ~500kb - 70ms - 14s

Nuxt w/ 10 Blog Posts w/ All Scripts Removed ~110kb - 8ms - 4.3s

You can see how my text is about ~100kb, framework is ~170kb, but the script it produces is 500kb because, I actually forgot, it's reproducing my content 3 times (did not bother to investigate why, just twice is bad enough imo)!

* Now, yes technically the throttled load times don't matter because the static html is loaded (they all paint, even throttled at around the same time), so there's no waiting for the page to load, but who knows what the rest of the background loading does to interactivity (on a proper site, with images, buttons, etc, this was just text) on slow phones with slow internet. Why would I do this to my users? It's not like it's even pre-loading anything useful (this test was with a single page, no other existing pages), imagine if it were.

> Using JS to render a new page is going to be faster than loading the entire static page.

Yes, the lack of a refresh is nice, I'll give you that and it's true that subsequent navigations are faster, but in my case I don't think it's worth the overhead. Plus, so much content changes per page, I could always just fetch the next page and replace the body manually without the overhead of a framework.

Don't get me wrong though, I would probably use a framework based SSG for say, a code blog, where it has more pros than cons. So I can see where most developers are coming from when they use them / design them.


Yea I think Nuxt must have started out with different priorities/tradeoffs than Gatsby did because Gatsby has the idea of sources which gives it a nice structure for specifying what processing/data fetching needs to be done at compile time vs at run time. It's super easy to just add a markdown source plugin (actually markdown support might be built-in) and it will compile it to HTML when your run the build and not on the client. There a ton of source plugins, but if you had to, I think it would be much easier to write one and use the provided abstractions than to write the pre-convert function you are thinking of.

You mentioned TTI (time to interactive) as a concern but that is a metric the Gatsby team seems to really be aware of from the beginning and I think they've done a pretty good job of dealing with it so far, see: https://www.gatsbyjs.org/blog/2017-09-13-why-is-gatsby-so-fa... In general though I've found client-side hydration to work pretty seamlessly in both React and Vue. I'll be shipping my first (non-trivial) Vue Server-Side Rendered app to production soon.

I think Gatsby would do a pretty good job even for content-heavy sites. It's built to try to only render the critical-path items. If you have a content-heavy site, you most likely have implemented some sort of summary list and pagination and only the first set of links on each static page are going to be prefetched by the browser. So it's not like you have to load all the data up front (and you probably shouldn't for UX reasons), you just have to organize the data appropriately like you would for any other kind of site. I've found that Gatsby's graphql interface makes doing these things a breeze compared to my previous React experience where I've had to mess around with state management libraries like Redux.

I'm confused by what you meant by "you can't take advantage of your framework to generate image tags". Is this in the context of Nuxt processing markdown on the client? Like I mentioned previously, this shouldn't be an issue with Gatsby and there are some cool plugins that, for example, allow you to process images in markdown during the build so that they are lazy loaded and initially show a low-res geometric representation of the image.

I can understand your hesitation to want to work with React though. I was hesitant at first. I would get annoyed at writing JSX, but once I got used to it, I found it tolerable and on rare cases I actually prefer it now.


So you got me to look more into Gatsby because it's good they're interested in performance, and what's interesting is it seems to automate the pre-fetching and lazy-prefetch based on if the link is visible (that I can get more on board with). That's really nice and also overall (especially with the GraphQL querying) it seems to be better suited for blogs than Nuxt so I can see where you're coming from. I wouldn't use it because React, but it does sound nice.

> I'm confused by what you meant by "you can't take advantage of your framework to generate image tags".

I mean that the framework needs to be handed the final html. It has no knowledge about the formatting inside a post. You have to rely on plugins, often third-party, which don't play well with each other.

I know I've gone on about bundle size (that was just the straw that broke the camel's back) but my main problem is that these frameworks don't help in going from the markdown to the final html which is 90% of the work. I'm not saying they should or can, just they don't, so they don't add enough value imo to be worth the overhead. This is true of all SSGs I've tried though. Yeah they always have a markdown plugin and, for example, that image loading plugin does sound really cool, but can I trust them to work nicely with other plugins? Do the plugins I need even exist? Will they be maintained? I can just feel I will end up fighting them and I've wrestled with too many SSGs already. I'd rather just try to roll my own at this point.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: