---
title: Speed up your Inertia.js website with these 7 tactics
url: "https://aaronfrancis.com/videos/speed-up-your-inertiajs-website-with-these-7-tactics"
path: "/videos/speed-up-your-inertiajs-website-with-these-7-tactics"
type: video
author: Aaron Francis
published: 2025-06-25
topic: "Laravel & PHP"
keywords: [inertia, laravel, performance optimization, ssr, asset prefetching, link prefetching, partial reloads, placeholder images, vue, dom optimization, laravel optimize, image transitions]
youtube_url: "https://www.youtube.com/watch?v=UNODn5b52u4"
site_index: "/llms.txt"
keyword_index: "/llms/keywords.txt"
---

# Speed up your Inertia.js website with these 7 tactics

## Chapters

- Snappy site demo
- Overview of the 7 step checklist
- 1. Server-side rendering setup
- 2. Asset prefetching
- 3. Link prefetching
- 4. Partial reloads
- 5. Walking the DOM
- 6. Placeholder images
- 7. Laravel optimize
- Final thoughts

## Transcript

**Aaron Francis:** All right, we're gonna see just how snappy we can make this Vue.js application feel. This is a Vue application that is backed by Laravel, and it has Inertia in the middle, which we'll talk about. But here is what we are after. This is the end state. So if we click on something, it basically is already loaded. So l- just kinda clicking around and seeing, wow, this, you know, this feels really snappy.

**Aaron Francis:** And if we go to Podcasts and we scroll down, we're like, "Oh, wow, that's really cool. A lot of podcasts. I wonder what this one's about." Boom. It just loads right there. I haven't updated the, the actual videos yet, but boom, just loads. Boom. Just like that. And you'll see the URL is changing, and I, I did very little of this. This is my new website, by the way. It's pretty good, right? Do you like it? Yeah, I haven't yet deployed it, but I'm very happy with it so far.

**Aaron Francis:** We're gonna look at a few different techniques. I think there's probably maybe five, six, or seven techniques used to make it feel this fast. Here's what we're gonna be doing. These are the... Wow, there's more than five. There's seven. These are the seven things that we're gonna be doing to make this site feel as snappy as we possibly can get it to feel.

**Aaron Francis:** So server-side rendering, couple of prefetches, partial reloads, which are very nice. This walking the DOM is an interesting one. When you have, um, content that is maybe written in Markdown or, uh, is written in some sort of CMS, we can walk the DOM and add a few things that make the links inside those articles a lot faster. And then we're gonna do placeholder images.

**Aaron Francis:** And finally, we're just gonna run the Laravel optimize command, which you should be running on every deploy, but hey, may- maybe we forgot, okay? Before we get too far into it, um, one of the things I love about Inertia is this right here. These are my routes for my application, and they're defined on the back end where I think they should go. And so when, whenever somebody hits /writing/article, this should pull up an article.

**Aaron Francis:** So we're, um, we're transferring over to the article controller and the show method. So if we click into there, this is the entirety of the route to show an article. This comes from Laravel. This is route model binding, so I will get the model out of the database thanks to Laravel. And then what I'm saying is, "Hey, Inertia, please render this Vue.js component." So I'm not, I'm not rendering a, a V-I-E-W, a view, I'm rendering an actual Vue.js page.

**Aaron Francis:** And then I say, "Here is the prop that I want you to inject." And I'm just taking that article and I'm putting a little wrapper around it so I can, uh, nicely define what goes down to the front end. And then if we open up, there we go, pages/articles/show, this is the component that gets rendered when somebody hits that route. And you can see the article comes in as an object.

**Aaron Francis:** You can type this. Uh, you can use TypeScript. You can use Composition API. You can do whatever you want. It's just Vue.js at this point. So that's how Inertia works. I think it would be interesting to check out server-side rendering with Inertia. Because, uh, I started this application just by doing Laravel new, it just comes, it just comes with server-side rendering.

**Aaron Francis:** And so you can see here how to install all the server-side rendering stuff for whichever front end that you're using. Um, but if we look in, let's look in our package.json, you'll see to build, we run vite build and then vite build ssr. And what that's gonna do is that's gonna run this one right here, and this will be, uh, the server-side rendered version of my application.

**Aaron Francis:** So if we were to stop the, uh, NPM run dev and did NPM run build, you'll see it runs SSR. It's saying, "Hey, a few of these images, I can't find it." That's totally fine. And then we get all of the assets spit out down here at the bottom. Now, for Laravel, all you have to do is run php artisan inertia:start ssr, and now the server-side rendering server is running.

**Aaron Francis:** Why do we have to do this? Because it's running a Node.js application to actually render that Vue component and then give back the HTML. So if we now hit refresh over here, and it wakes up, there we go. So, and we look at this, um, let's actually do View Source. And we come over here and we scroll all the way.

**Aaron Francis:** It's all compressed. Look, we see actual HTML in here. So you'll see that coming from the server, we're getting actual HTML with the entirety of the contents, and then it gets hydrated. So that is step number one, and that is, um, I guess that's less for performance and more for, uh, SEO or, um, I guess honestly, AI agents at this point.

**Aaron Francis:** Um, but the first request is now going to be server-side rendered. It's gonna come down with all of the content. That's good. And after this request, now we're in client-side land. So Inertia looks at, uh, the next clicks that we're gonna make and says, "Ooh, hang on, let me intercept those, and instead of doing a full page refresh, let me just go get the data and come back and put that into the page." So let me, um, let me hop over here.

**Aaron Francis:** We're just gonna refresh, and then we're going to open this up, and we'll just leave the network open. Now if I click on Strategies, and then I come down here and I click on Become Known, and then we check out-- Let's check this out. So there you go. This is the request that went out to... Where's the URL? It went out to writing/85.

**Aaron Francis:** And the response is not, is not a server-side rendered component. It is not HTML. It is just JSON. It says, "Hey, here's the, here's the Vue component that you should use, and here are all of the props." And you can see those are the props from our article resource. And then when I clicked on the next article, it did the exact same thing, and it said, "Here's the component.

**Aaron Francis:** Here are all of the props." So that's how we transition from server-side rendering to client-side rendering. The first request is going to be fully server-side rendered, send down all of the HTML. After that, Inertia is gonna step in. Provided we do everything right, Inertia is going to step in and do the client-side routing for us- But we don't, we don't have to handle that.

**Aaron Francis:** We get that for free with Inertia. Okay, we have done, uh, server-side rendering, and asset prefetching's gonna be super fast, so I'm just gonna mark it off right now. But before we do that, I need to show you something super cool. Look at this. Hey, that's me. That's me on the homepage of bento.now.com. Bento is the email service provider that I use for my newsletter, which is very good, please sign up for it, and for all of the courses that we create.

**Aaron Francis:** It is both marketing and transactional email, and it's run by one of the best guys on the internet. Support is absolutely top-notch. If you need anything, you can reach out to the founder directly, uh, and he will help you. So thank you to Bento for sponsoring this video and so much of my work. Uh, Jesse at Bento makes this kind of stuff possible.

**Aaron Francis:** So y'all go check out Bento at bentonow.com. Now, back to the show. Asset prefetching. Let's go to the Laravel docs, and one thing we can do is asset pre... Maybe it's under asset bundling. There we go. And if we do prefetch and come down to the docs here, you'll see, "When building an SPA using Vite's code-splitting feature," which is what we're doing, uh, "required assets are fetched on each page navigation.

**Aaron Francis:** You can instruct Laravel to prefetch your assets." That sounds nice. That sounds really nice. Let's go ahead and do that. So we're gonna do this, and this will, um, this will help avoid fetching a whole bunch of little bitty JavaScript files, um, thanks to Vite, who split it all up quite nicely, which is great for caching, but on the first couple of loads can be kind of a pain.

**Aaron Francis:** So we're just gonna say, Vite, prefetch, turn it up, baby. So now we have asset prefetching, and that will help, um, subsequent navigations feel a lot faster, 'cause it'll be cached, uh, which is one of the nice things about Vite is how it splits everything up so nice and small. Now, asset prefetching done. Link prefetching.

**Aaron Francis:** This is something entirely different. This is not, um, prefetching assets. This is the thing where if you hover over a link, you're probably gonna click it, so we can go ahead and fetch it a little bit early. And to do that in Inertia, what do you do? You put the word prefetch on your link. That's it. So Inertia provides this link component that is very powerful, and if you throw prefetch on it, then you get that nice hover, um, you get that nice fetch

**Aaron Francis:** on hover. So let's come back here. I stopped the SSR server. So if we run NPM run dev, we should see... Let's wake everybody up over here. Wake up, wake up, wake up. And we'll clear that out. Now, when I hover one of these links, you should see a request go out. There you go. Boom. So I didn't click on anything. It sent a get request out, and what was returned was the Inertia response.

**Aaron Francis:** So it says, "Hey, if they click on this, this is what I'm going to return to you, and you should use the video/show, uh, component." So now you'll see that it is, uh, I think it's cached for, like, 30 seconds by default or 60 seconds by default. You can change that. But now when I click on it, it loads super fast.

**Aaron Francis:** So you can see, um, coming back here... Oh, I hovered it, and the, even the logo has prefetch on it. So if we look at, uh, if we look at all of our nav links, this is the nav link component right here. You'll see we're using, uh, Vue.js' or rather Inertia's Vue link component. So we're importing that from Vue 3, and we put prefetch on it, and that's the thing that gives us...

**Aaron Francis:** Some of these are, uh, I haven't made the pages yet. But that's the thing that gives us this nice, quick, snappy feeling right here. If you were to use just a regular, uh, A tag, prefetch makes no sense there, but if you were to use just a regular A tag, uh, Inertia is, is not gonna be in control of that link click, right? So we clicked on that, and goodness knows where it is, probably in there.

**Aaron Francis:** See it did a full, it did a full page reload. It got the HTML, the head, the body. We had to load all those assets again. That's not what we're after. So rule number one, avoid using, uh, for internal links, avoid using an A tag. Use a link instead. And if you wanna throw prefetch on it, that is gonna make everything feel a lot snappier.

**Aaron Francis:** Okay, we have done link prefetching. Partial reloads, even cooler than link prefetching. Partial reloads. So we have a page like this, right? Whoa, what a great page. Very good design, Aaron. Thank you. I appreciate that. We have a page like this, right? And then you get down here at the bottom and you're like, "Oh, that looks like a little, that looks like a little menu, right?

**Aaron Francis:** What if I click on it?" Oh, we didn't even, we, we didn't even see anything happen except that we got the new title and the new description down here. So you click on it. Oh, wow, the URL changes also. This is an Inertia partial reload. So instead of... We're, we're kinda going in, um, we're kinda going in a gradient here.

**Aaron Francis:** So, um, the worst one, the worst one would be full page reload. Eh, it's not terrible, but if you can get away with not doing it, you definitely want to. Then after that, we have Inertia, uh, you know, Inertia swap component. We'll call it that. And then after that, you've got one that's even better than that.

**Aaron Francis:** Inertia just get new props. And this goes from, uh, this goes from worst to best. So this is what I just showed you right here. I just showed you swap component. So we did the prefetch, which made it super fast. But we don't even-- If we're gonna stay on the same component and we just wanna switch out a part of the data, like we just wanna get new props, we can do that with a partial reload And you can do that with just

**Aaron Francis:** the Inertia link component again. So, uh, we're looping over all of the podcasts here, and we're putting in the podcast title, right? So that's where we're building out that nav bar. And then in the link itself, we're saying, um, only fetch these two props. So don't actually fetch all of the props, but when somebody clicks on this, the only thing that can be updated are the props podcast and episodes.

**Aaron Francis:** And we also say preserve the scroll so that it doesn't jump around when they're clicking on the menu and preserve the state, the other state. So we're gonna keep all the state we were given. We're gonna go off to the server, and we're gonna fetch podcast and episodes. We're gonna merge that and, in fact, prefetch it, and then we will... Vue just takes over and updates the component when the props change.

**Aaron Francis:** So if we come down here to props, you'll see cards and podcast. Uh, actually, cards and podcasts are the ones that don't change. Now, whenever we click... Let me, uh, you know, let me just open that. So whenever we click on Mostly Technical, we need to switch to A- XHR, make this bigger.

**Aaron Francis:** Mostly Technical, there you go. The only props that come back are podcast and episodes. The other props do not come back. And so we're doing a partial reload that says, "Only get those new props. Don't change the rest of the state. Preserve the scroll." And then on the back end, what we do is podcast controller.

**Aaron Francis:** Um, we can do it like this. So we can say, um, return the podcast/index page. Here are all of the props, but in fact, you can wrap this one in a closure, and that way Inertia, when it says... when it comes back and says, "I just wanna get podcast and episodes," it sees that podcasts is wrapped in a closure, and it says, "Huh, I'm not gonna evaluate that.

**Aaron Francis:** I don't have to evaluate that because you asked for podcast and episodes. You didn't need the list of podcasts again. That hasn't changed. You didn't need the two big cards that go at the top. That hasn't changed." And so if we left that out, because of the way the language works, there would be no way to not run that code.

**Aaron Francis:** But when we wrap it in a closure, now Inertia can say, "Nah, I don't need to evaluate that closure." So this could potentially be quite expensive, but it doesn't matter 'cause we're not gonna reload it. We're just getting back those two props. That's all that matters. So that is a partial reload. Pretty cool, huh? Next thing we're gonna do is we're gonna walk the DOM.

**Aaron Francis:** So in my, uh, in my situation, I've got an article. The article comes from Markdown on the back end, but I wanna walk through and look for links that should be turned into Inertia links so that we get all of these benefits even inside the body of the article. Let me show you an example first. So I'm on this article, Strategies for Increasing Your Odds of Success, and I'm reading it, and I'm like, "Wow, this is really good.

**Aaron Francis:** Oh, here's a link. Let me click on this link." Click on it, boom. Totally done. Because it's an Inertia link, and in fact, we manually prefetched it. Now, like I said, this content all comes from the database. It's generated by Markdown. So how did we get in here? We got our grubby little paws on it, okay?

**Aaron Francis:** So this is the article's show page, and if we come down to... Let's look for VHTML right there. In the article, uh, in the article container, we're saying set the HTML to processed article HTML, which gives you a hint we're about to muck around with the HTML. We're about to process it. That sounds a little more official.

**Aaron Francis:** And then on the, um, container itself, we have this click handler, which is handle article click on this big parent container. And then, of course, we have a bunch of Tailwind, right? So let's go down to processed article HTML. The first thing that we're going to do, the first thing that we're going to do is make sure that there's some HTML, and then we're gonna create a temporary div 'cause we don't know if this has been mounted yet or we're still in the creation phase.

**Aaron Francis:** Doesn't matter. We're gonna put the, um, HTML into this temporary div, and then we're gonna select all links that have an href on them. Then we're gonna walk them. So we're gonna walk them, we're gonna pull, uh, the href, and we're gonna see is it an internal link. Very basic. I won't show you it's... 'cause it's kinda boring, but b- basically just saying, are, are the origins the same?

**Aaron Francis:** Is this pointing to the same website? And if it is, all we do is set data-inertia to true, which is not an official thing. We, we handle this later. This has nothing to do with the actual Inertia library. I just thought it was a good name. Now, this, on the other hand, is quite interesting. So instead of, instead of, um, swapping out the A tag with this link component that we then have to get Vue to pick up and render, we're, we're not gonna do any of that.

**Aaron Francis:** We're just manually going to prefetch anything that is in the body of this article, and we're just gonna hang on to it for five minutes. It's an article. What could possibly change in five minutes? We could probably bump that to an hour, and it wouldn't matter. So we add an attribute, and we manually prefetch it through Inertia. This import router is up here.

**Aaron Francis:** So we import the router from Inertia. And then we just manually prefetch it, which is totally, totally legit. It's in their docs. This is not a weird workaround thing. You know, we also add target blank to any external links. That's kinda nice. We just did that 'cause we're here, right? And then we return the innerHTML of that div. Now- The article click becomes very simple.

**Aaron Francis:** We just test to see if data-inertia is on that link, and if it is on the link, we can use... I used this one, um, to show that it is globally available. We could also just use router.visit, and that will, um, initiate an inertia visit instead of a full page reload. And that's exactly, that's exactly how we get this here.

**Aaron Francis:** So we, um, we already prefetched it on load, so it's been prefetched, and then we click on it, totally loaded. That is walking the DOM. Placeholder images. You may have noticed, if you're paying very close attention, you may have noticed these images... Oh, wow. That was a good one. These images start out blurry, and then they, uh, they kind of, uh, crisp up, right?

**Aaron Francis:** So what we're doing here is I am sending down a very small Base64 encoded version of this image. So when the page loads, you get some sort of sense of what that image is going to be, even if it isn't fully, even if it hasn't fully popped in yet. And in production, we'll be using Cloudflare, so these images will load very quickly, but still.

**Aaron Francis:** I like this. You get a sense of what the image is. The DOM is all where it should be with the right sizing and everything, and this is actually, this is actually very simple. So I've got, um, I've got this image component, image.view, and it just, it just basically has two images. It's got the real one down here and the fake one up here. So if we pass a placeholder through, we're gonna use that placeholder, and this is the Base64 part, which I'll show you in a second.

**Aaron Francis:** And then we do some stuff to make sure that, uh, to make sure it shows up in the right place. And then once this image loads, we turn the opacity up to 100. Now, the reason we're not using a v-else here is because if you keep it out of the DOM, it's never gonna load, and so your callback will never get triggered. So onImageLoad, I should probably just inline that, 'cause all it does is set loaded to true, and that's where we get this nice, uh, the duration, the transition duration is 800 milliseconds.

**Aaron Francis:** That's where we get this nice little effect right there. So you see the blurry one pops in, and then if we change this to, like, I don't know, uh, let's change this to, like, 3.8 seconds, and we did that again. If we hard refresh. Now it's just loading. There we go. Boom. And super slow.

**Aaron Francis:** And there you go. So that's what it would look like if we did it super slow. Now, the way that we create these, if we get to the article resource, you'll see that placeholder is this.placeholder or arrow placeholder. So let's go over to the article itself. It's very simple. In here, we have placeholder attribute.

**Aaron Francis:** So this is the article model, and we're creating a placeholder attribute. We're gonna set it up. Uh, we're gonna cache it so that we're not doing this image manipulation a bunch. So we're gonna use... The key is going to be the og image, so if we ever change the image path, the cache will get busted. In fact, if we ever modify the file, the cache will get busted.

**Aaron Francis:** So this makes sure that, um, any time we update the og image, the placeholder gets reset. And we're using, uh, a package called intervention:image, and all we're gonna do is we're going to, uh, read off of the disk. We're gonna get the image itself. We're gonna scale it down, which, uh, retains the proportions. We're gonna scale it down to 400 pixels.

**Aaron Francis:** We're gonna blur it, and then we're gonna make it a really crappy JPEG at 30% and then send it out as Base64 encoded data. That way, when the page loads, the image is already there. It's embedded. It doesn't have to go off and fetch it. And that means when we hover on a link and prefetch it, that image was prefetched.

**Aaron Francis:** That placeholder image was prefetched, and then when they click on it, they'll see something, and then hopefully, hopefully that image, uh, the real image will pop in pretty quickly. This has nothing to do with inertia. This is just a little, you know, Laravel plus Vue.js. The last one. We did it. Placeholder images. Laravel optimize. So I am running locally.

**Aaron Francis:** This is not something you would run locally. Um, but let's just go ahead and build it for real. So let's do npm run build. This is what we would do on deploy. We would run npm run build. That would all finish. Then we would run php artisan optimize. That would all finish, and what this does is this, um, configures the framework for production.

**Aaron Francis:** So it does the... It caches the config, the event, the routes, and the views. So it doesn't have to go and look up a bunch of stuff. You don't wanna run this in development, 'cause that will... That's gonna be very annoying. Uh, and then we can run php artisan inertia:start ssr. So now we're back, we're fully back to what a production deployment of this would look like without Cloudflare, which is pretty important for assets, but that's fine.

**Aaron Francis:** And now we are done. Now we're done. So we come back here. Everybody's gotta wake up, wake up. There we go. And now we hit podcasts, and we get the partial reload, and we come out here, and we get the hover, and we come down here, and we get the hover, and it's a pretty fast site, okay? I'm pretty, I'm pretty happy with this.

**Aaron Francis:** You can use, you can use all of these tricks outside of Laravel and Vue. Um, I would highly recommend looking at Inertia regardless of what stack you're using, because it gives you that nice, um... You get to use all of the power of your backend framework and all of the niceties of your frontend framework without a bunch of crap in the middle, right?

**Aaron Francis:** Without writing your own router or anything like that. Inertia binds the two together, and it's got bindings for a ton of backends and a ton of frontends. If you can think of anything that I've missed or a way to make this faster or better, or if you just absolutely love my new website design, please let me know. Either way, let me know what you think in the comments down below.

**Aaron Francis:** And you know what? Go sign up for Bento. Go sign up for my newsletter, aaronfrancis.com. Until the next time, see ya.

---

## Related on aaronfrancis.com

- [This is a season of Type Two fun](/newsletter/this-is-a-season-of-type-two-fun) *(Newsletter · 2025-08-08 · shared: vue, laravel, inertia)*
- [Aaron Francis: Building and Teaching Cool Things](/podcast/aaron-francis-building-and-teaching-cool-things-39697cbb) *(Podcast · 2025-03-11 · shared: inertia, laravel, vue)*
- [Aaron Francis is putting PHP in Your JS Files](/podcast/aaron-francis-is-putting-php-in-your-js-files-6f3117a7) *(Podcast · 2025-03-05 · shared: laravel, inertia, vue)*
- [Fusion: Write PHP inside your Vue and React components](/podcast/fusion-write-php-inside-your-vue-and-react-components-cdf3a9e4) *(Podcast · 2025-02-14 · shared: laravel, vue, inertia)*
- [#33 - Aaron Francis on Fusion, TUIs and Content Creation](/podcast/33-aaron-francis-on-fusion-tuis-and-content-creation-087d6b18) *(Podcast · 2025-02-13 · shared: inertia, laravel, vue)*

## Relevant Resources from Aaron Francis

- **[Solo](https://soloterm.com)** (overview on site: [/software](/software)): All-in-one agentic development platform and terminal workspace built by Aaron Francis for orchestrating processes and AI coding agents.

## Search aaronfrancis.com (2-Hop Static Keyword Index)

Pick the alphabetical shard matching any topic to find exact pages across all articles, newsletters, videos, talks, and podcast transcripts (every shard is < 40 KB):
[A-B](/llms/keywords/a-b.txt) · [C](/llms/keywords/c.txt) · [D-E](/llms/keywords/d-e.txt) · [F-G](/llms/keywords/f-g.txt) · [H-J](/llms/keywords/h-j.txt) · [K-L](/llms/keywords/k-l.txt) · [M-N](/llms/keywords/m-n.txt) · [O-P](/llms/keywords/o-p.txt) · [Q-R](/llms/keywords/q-r.txt) · [S](/llms/keywords/s.txt) · [T-Z](/llms/keywords/t-z.txt) · [Directory](/llms/keywords.txt) · [Site Map](/llms.txt)

Shards for this page's topics: `inertia` ([H-J](/llms/keywords/h-j.txt)), `laravel` ([K-L](/llms/keywords/k-l.txt)), `performance optimization` ([O-P](/llms/keywords/o-p.txt)), `ssr` ([S](/llms/keywords/s.txt)).

## About Aaron Francis (Current Context)

Aaron Francis is VP of Marketing and Community at [Laravel](https://laravel.com), founder of [Try Hard Studios](https://tryhardstudios.com), creator of [Solo](https://soloterm.com), co-host of [Mostly Technical](/podcast), and author of [Mastering Postgres](/courses), [High Performance SQLite](/courses), [MySQL for Developers](/courses), and [Screencasting.com](/courses). Full bio: [/about](/about) · Current focus: [/now](/now).
