4 ms·
I can do the same thing via NextJS and output pure HTML and CSS without any JS at all. Or with server components, output only the minimal JS needed. Not sure wh
by satvikpendem 3y ago
I can do the same thing via NextJS and output pure HTML and CSS without any JS at all. Or with server components, output only the minimal JS needed. Not sure why everyone wants to write a programming language inside HTML like lit does.
- spankalee 3y agoHow is Lit's use of JS in templates any different than JSX? Both use JS for expressions and control-flow.
- ReD_CoDE 3y agoJSX is expensive than JS, because JSX first needs to become JS, then other things happen
- spankalee 3y agoThat doesn't speak to this comment: > Not sure why everyone wants to write a programming language inside HTML like lit does When that's exactly what the OP's suggestion of React does.
- earthboundkid 3y agoThere are a bunch of server side apps that turn JSX into static HTML with no JS. It’s just a template language that compiles into JS but you can do anything with it you could do with other template languages.
- FireInsight 3y agoThe king of "use JS frameworks, output pure HTML" is Astro. (https://astro.build/ https://astro.build/) It's basically an SSG where you can use a number of frameworks to write your components, and shipping any JS is explicitly opt-in.
- satvikpendem 3y agoAstro is pretty nice too, I was going to write my blog with it but I liked the instant page transitions that NextJS provides out of the box for which I couldn't find a suitable solution in Astro.
- toddmorey 3y agoAstro is adding (optional) client-side routing. I’m excited about that.
- jen729w 3y agoDoesn’t NextJS do that with client-side JS though? I recently moved from Gatsby, which did that — and the transitions sure are instantaneous — to Astro, which outputs plain HTML pages. Each navigation is a request to the server. Yeah, they take a touch longer. But the response is tiny. You could always `preload`?
- satvikpendem 3y agoI tried preload, it doesn't work as well as with NextJS which, yes, uses client side JS. But critically, the pages still work without JS if one so chooses. It's progressive enhancement which Astro does not yet have.
- vegcel 3y agoCould you explain a bit what you do like/don't like about Gatsby compared to Astro?
- satvikpendem 3y agoI used to use Gatsby, but the non standard plugin system as well as forcing GraphQL (I use GQL in my own projects but it's just not necessary for a blog site for example, which Gatsby markets itself as being for) put me off Gatsby and onto NextJS, especially when NextJS introduced their static site rendering features. Now with server components, there doesn't seem to be a real need to use Gatsby anymore.
- password54321 3y agoA fresh install of NextJS is roughly 150MB. You realise that's mostly code that all needs to work right?
- satvikpendem 3y agoThat's all on the backend so it doesn't really matter to me as long as no JS is sent on the frontend. For the benefits NextJS gives me, like TypeScript, I'm fine with that.
- e111077 3y agoIn that case why not just SSR lit on the backend and send that? It sounds like an unfair criticism otherwise
- robertoandred 3y agoIt's easy to add interactivity to a NextJS site when you need it.
- e111077 3y agoLikewise with Lit, but that is besides the criticism that he was making earlier
- satvikpendem 3y agoI have the full React framework and ecosystem if I so choose to use it. For example, I could use something like react-three-fiber to add 3D or Framer Motion to add animations yet fall back to not having those when JS is disabled. Sure you could do the same in Lit but those libraries aren't present or as robust as in React.
- MatthiasPortzel 3y agoNextJS sends all JS to the frontend even if it's static and server rendered. It renders once on the server, sends a React+JS bundle to the client, and re-renders the whole page on the client (which is exactly the same). As far as I could tell, there's no mechanism for Next.JS to say "this isn't dynamic" and send only HTML content. If there's a setting I missed, feel free to let me know.
- wsatb 3y agoYou can use lit components within Next, or within anything really. If you’re building a single app, use what you’re comfortable with. At my job, we’re often creating components that need to be used within an increasing number of frameworks because every client is using something different. Having a custom element instead of needing to load React on every client’s website is huge.
- satvikpendem 3y agoInteresting, at the workplaces I've been at, we only used React, nothing else, in order to make the code-sharing problem much easier, as well as not have developers learning many different frameworks just to get work done.
- earthboundkid 3y agoBut wouldn’t you be happier if each and every component on the page paid the price of a full templating system? No? Oh yeah, I forgot that Web Components are a terrible idea that are only marginally successful because they can claim to be a “standard” when they’re not any more standard than any other JavaScript.
- spankalee 3y agoYou only "pay" for as many template systems as you use, not one for every component, and modern template systems are far smaller than the major frameworks.
- earthboundkid 3y agoEach independent script you import is another load blocker. You could have scripts A and B both import template C, but then you're slowing things down even more, and no "HTTP2 push!" is not the answer.
- satvikpendem 3y agoI honestly don't know how WCs got through the standards process successfully, they're so bad.