Struggling with My Vite Website's Load Times - What Should I Do?
Asked by
DevNinja42
Hey folks! I've recently started my web development journey after coming from a background in low-level game development. I wanted to create a website to showcase my projects and games and kicked things off using 'npm create vite@latest'. Everything was going smoothly for a while as I experimented with small projects. Eventually, I learned about frameworks like Next.js and concepts like Single Page Applications (SPAs) and Static Site Generation (SSG).
However, I've realized that my SPA might be slowing me down. After diving into backend development and creating numerous pages, I noticed my site's load times were around a secondโa fact I initially brushed off as a connection issue. Recently, I wanted to explore Server-Side Rendering (SSR) but discovered that my current SPA setup wouldn't support it. Now I'm contemplating what to do next. I'm hesitant to rewrite my whole app in Next.js, and although I've considered using Astro, I'm uncertain if it would resolve my speed problem. Should I just accept the slow load times, try out Astro, or transition to Next.js while I still can? Any advice would be greatly appreciated! Also, I forgot to mention that I used React.
Answers
So, when you say โticking time bomb,โ it sounds like you're worried about how your site will handle growth? Since you mentioned the load times, it could be due to the way your app is structured. Make sure youโre not loading everything up frontโtry splitting your code on routes using lazy loading. It wonโt help with SEO, but it'll definitely speed things up!
Reply to this answer
Have you checked the SSR section in the Vite docs? It might give you some insights into how to optimize your current setup without needing to switch frameworks entirely. Here's a link: [vite.dev/guide/ssr.html](https://vite.dev/guide/ssr.html).
DevNinja42: I haven't looked yet, but I will! Thanks for the tip!
Reply to this answer
Definitely give Astro a shot! If you didnโt specify a framework while using vite@latest, you could easily integrate it. Since Astro is great for static sites, it might be the right fit for your needs, especially since your website is more of a personal project without heavy interactivity at the moment.
DevNinja42: I'll look into Astroโsounds promising! Iโm curious if it can handle more interactive content as my projects grow.
Reply to this answer
Add your answer
Answers are reviewed before publication.
CuriousCat99: That's a great point! Would lazy loading mean the content only loads when it's needed?