Skip to main content

Syntax Podcast

Hasty Treat - Turbolinks + Server Generated HTML + JS Sprinkles

Wes Bos Host

Scott Tolinski Host

Overview of Turbolinks for fast page loads using server-generated HTML and discussion of integration with JavaScript frameworks.

Topic 1 00:00

Transcript

0:00

Announcer

Monday. Monday. Monday.

0:02

Announcer

Open wide dev fans. Get ready to stuff your face with JavaScript, CSS, Node modules, barbecue tips, get workflows, breakdancing, soft skill, web development, the hastiest, the craziest, the tastiest web development treats coming in hot. Here is Wes Barracuda Bos and Scott El Toro Loco

0:28

Scott Tolinski

Welcome to syntax.

0:29

Scott Tolinski

And this Monday, hasty treat. We're gonna be talking all about Turbolinks. It's turbo dime. Oh, that was terrible, Arnold. I usually feel like I'm pretty good at that. It's turbo time. We're gonna be talking about Turbolinks and server generated HTML, plus some j s sprinkles in there. I love that you wrote j s sprinkles in this episode title Wes. My name is Scott Tolinski. I'm a full stack developer from Denver, Colorado. And with me as always JS Deno Wes, boss. Hey, everybody.

0:56

Scott Tolinski

Hey, Wes.

0:57

Scott Tolinski

Yeah. So this episode, we're gonna be talking all about Turbolinks.

Topic 5 05:59

Comparison to PJAX

5:59

Scott Tolinski

It's funny. When I hear some of this, I think about PJAX. Do you remember PJAX? Did you for use the Exact same thing. Yeah. So Pjax, I don't remember the technical ways of doing this, but I used it even inside of Drupal, even though Pjex, I think, was a, Ruby thing first in Bos, wasn't it? So was this. I think so. Yeah. I believe Pjex came out of Rails. I'm not positive about that. But, it it basically allowed you to get the client side style routing where a section of your site was reloading without the, let's say, navigation of the site. So, like, a part of your site would stay where it JS, and the other parts would be swapped out via JavaScript.

6:39

Scott Tolinski

But it was very easy to do and very much so that you just, like, basically included some links and had some specific nav be the Pjax links, and it just worked. That's all I remember, specifically. It was jQuery Bos? I think it was jQuery based. I'm not positive about that. So it's it's so funny. I'm, like, working off of memory here because this was 2011

6:59

Wes Bos

that I was using Pjak. So it was quite a bit a while ago. Yeah. It it's kinda interesting. Like, if you go to like, Basecamp was the Scott of the people that made this popular, and they are the developers behind Turbolinks, the JavaScript library. And then you obviously have to still have a, like, a server side portion of that as well. It's it's there's adapters for Node and for for most likely for Rails because that's what, Basecamp uses.

7:25

Wes Bos

But if you just go in the dev tools and click a page, you'll see that request. And then and you can look in the response tab of that request.

7:33

Wes Bos

And instead of seeing raw JSON, you just see HTML, which is kinda cool.

7:38

Wes Bos

So the question is, like, okay. First of all, maybe, like, like, what's the benefit to that? I guess the the benefit to that is that you don't ship as much JavaScript to the client.

Topic 7 08:16

JavaScript still needed for interactivity

8:39

Scott Tolinski

that's a good question, actually. I don't know if you can use, like, a React for something like this Wes you just want parts of it to be dynamic. Yeah. You can. Absolutely. Yeah. Yeah. It's funny because when Vue teaches Vue, they say, like, oh, here, just use Vue for this little tiny bit. But when React teaches React, they're like, you gotta use create React app. And I know that's not, like, how they're intending it to be, like, taught, but, like, definitely, you can you just basically, you just pick a a dev, and you say, hey. Render my React components into this dev. And you have multiple

Topic 9 09:33

JavaScript sprinkles overview

9:44

Wes Bos

Yeah. So Stimulus was sort of the first one. Alpine JS is gaining a lot of popularity. It seems pretty cool and have very much a Vue Angular Node approach, where you just write your HTML in a certain way and the JavaScript library will just pick it up from there and and allow you to do things like looping and handling clicks and showing and hiding and those sort of basic stuff that you might wanna do in the browser. But it's it's all done in your HTML templating language, which is pretty nifty.

10:19

Scott Tolinski

Yeah. Very nifty.

10:21

Scott Tolinski

Man, I I love the term sprinkles here. I'm thinking about how I can bake some sprinkles into my cake and get a funfetti cake of web dev. Yeah. This is not something I've I've used myself, but I thought we just do, like, a little show

10:37

Wes Bos

because you're gonna hear it thrown all around quite a bit. I've seen back when React suspense was supposed to come out sorry. Not when it's supposed to come out. When they first demoed it, showing a demo where React was not running on the client. It was just running on the server, And then there was just a thin layer of JavaScript running on the client, and it would fetch back to the server the different pieces that needed to be rerendered.

11:05

Wes Bos

And I'm wondering because React is not I have no inside information, but I wonder if React is looking at this as as an option because they haven't released suspense. They're looking at making React Vercel like a first class citizen Vercel side render.

Topic 10 11:06

Potential future React suspense usage

11:20

Wes Bos

And I wonder if they're looking at, like, can we build something like this Wes instead of doing all of the rendering and hard stuff on the client, can we just fetch HTML diffs and then dump them into their corresponding Mhmm. Pieces on the website or the entire page? That's why I wanted to do this because I I think that it's something that might become more popular in the next couple Yarn. Totally. I I wonder about this too. I mean, I'm I've been doing server side rendering with React for a very long time now.

11:50

Scott Tolinski

That initial experience isn't really isn't really I don't wanna say it's not terrible because it's not terrible. I don't but that that sounds like bad to say. I don't think it is terrible. Yeah. It creates the HTML. It creates it with all of my data, and it just spits it out on the page. And that initial page JS, in fact, like, fully Vercel side rendered. Hey. That's possible. The next step becomes, like, how can we bridge the gap between then the next client side bit Wes you click a link or you do something? What's that next bit look like in terms of how does react react to those changes? It's all very fascinating to me. It's a a fascinating world to explore. I'm gonna check out some of the stuff. And and it's Sanity. We didn't mention in this episode that Turbolinks is not new. It's been around for Nope. Since 2015.

12:36

Scott Tolinski

That said, I I Node it's probably gone through several additions, and it actually they made it really easy to add to a rails project because I I used to do Rails work myself, and I I remember when Turbolinks were, like, just coming out as, like, a thing. So it's a fascinating world, and I think we're to see a big shakeup. This this next generation of frameworks, whether or not React changes significantly or doesn't change at all or or goes in some of these directions, I think it's going to be a very, very interesting time for us as developers.

13:05

Scott Tolinski

And I I'm sure there will be you know, I I don't think front end framework people are just going to sit around and watch the the web go to, you know, primarily server rendered web and do nothing. We're gonna see evolutions. We're gonna see growth. We're gonna see advancement. I mean, heck, I just think about Svelte and, all of the cool things that Svelte does in some of these regards. And, wow, I I'm excited for the future of web dev. So, man, that's that's my attitude about this. No. It's another kinda cool thing about this, and and Next JS is kind of doing this already.

Topic 11 13:06

Evolution of frameworks

13:38

Wes Bos

And I wonder if they're they're looking towards this as well where they have, like, these, like, statically generated on demand pages. So it's all it's generated on the Vercel, and and and then it's static, and then it will serve it up the next time as static. Yeah. But what's cool about that is you could, like, put raw SQL queries in a in a React hook and then just ship HTML to the thing. And I I I realized we're kind of reinventing the wheel because that's what Webex has been for all these years. But Right. Then you might not even need to worry about, like, having a publicly facing GraphQL API because Yeah. You don't need to query it from the client. It's just done on the same server. And we only query from our API

Topic 13 14:36

Wrap up

14:36

Wes Bos

There's something here. Now that we don't totally know what it is, but I thought we would do the show just to sort of keep you on it knowing that this is maybe something that will become popular in the next little bit or already is popular.

14:47

Scott Tolinski

That's about it. Yeah. Cool. Well, I I had a great time pontificating some of this stuff with you. I'm really interested to hear and and maybe check out more and, again, see where all this goes. And and I know it seems like the React team is on it or at least there's something brewing there. So who who knows? Excited for the future here. Beautiful. Alright. Thanks for tuning in. We'll catch you on Wednesday. Peace. Peace.

15:10

Scott Tolinski

Head on over to syntax.fm for a full archive of all of our shows. And don't forget to subscribe in your podcast player or drop a review if you like this show.

Quote it with credit and a link. Quoting Syntax

Share