Lovable app slow first load: find the huge bundle and cut it down

By AI App Medic · Updated · Lovable · Performance · Vite

A lot of Lovable (and Bolt, and Cursor) apps feel fine to the person who built them and slow to everyone else. The first visit sits on a blank or almost-blank page for several seconds, then the whole UI appears at once. The usual cause is not a "slow server" in the way people mean it. The browser is downloading and parsing a large JavaScript bundle before React can paint the first real screen.

Our own scans of public Lovable apps often show initial JavaScript in the several-hundred-kilobyte to megabyte range, uncompressed. You do not need a special hosting plan to start fixing that.

Step 1: measure the published URL, not the preview

  1. Open the production URL in a private window. In Chrome DevTools, turn on Disable cache, set Network throttling to something like "Fast 3G" or a mid-range mobile profile, and reload.
  2. In the Network panel, sort by size. Note the main /assets/*.js files. If one file is most of the download, that is your target.
  3. In the Performance or Lighthouse panel, look at Largest Contentful Paint (when the main heading or hero image appears) and at Total Blocking Time. You want a number you can compare after each change, not a vague feeling.
  4. On the machine that has the project, build for production and inspect the output:
npm run build
npx vite-bundle-visualizer

Or, with the rollup visualizer plugin, generate a treemap of dist. The point is to see the packages by name: a full icon set, a chart library pulled into the home page, moment.js, a PDF toolkit, animation libraries, or lodash imported as a whole.

Step 2: stop shipping everything on the first page

Route-level splitting is the change that usually pays off first. Do not import the dashboard, the settings screen, or a heavy chart from the root file.

import { lazy, Suspense } from "react";
import { Routes, Route } from "react-router-dom";

const Dashboard = lazy(() => import("./pages/Dashboard"));
const Settings = lazy(() => import("./pages/Settings"));

export function AppRoutes() {
  return (
    <Suspense fallback={<p>Loading…</p>}>
      <Routes>
        <Route path="/" element={<Home />} />
        <Route path="/dashboard" element={<Dashboard />} />
        <Route path="/settings" element={<Settings />} />
      </Routes>
    </Suspense>
  );
}

Load charts, rich text editors, maps, and PDF previews only on the screen that needs them, the same way. If you use a TanStack Start (newer Lovable) project, use that framework's lazy or server-split helpers instead of copying the React Router snippet blindly. The idea is the same: the first paint should not include the admin chart.

Step 3: cut the libraries that dominate the treemap

Rebuild and compare the gzip sizes in dist/assets after each removal so you know which change mattered.

Step 4: images, fonts, and third-party scripts

A 3 MB PNG hero will ruin LCP even after you shrink the JS. Export a reasonably sized WebP or AVIF, set width and height (or CSS aspect ratio) so the page does not jump, and lazy-load images below the fold with loading="lazy". Do not lazy-load the hero.

Fonts: prefer one family, font-display: swap, and only the weights you use. Self-hosting a subset, as many Vite templates can, avoids a long block on a third-party font CSS file.

Analytics, chat widgets, and A/B tools should load after the page is interactive, not in the critical <head> with no defer. Each script contends with your bundle on a slow CPU.

What usually is not the first problem

Supabase latency can make lists feel slow after the shell has painted. Fix that with indexes, narrower selects, and less data on the first query, but measure it separately from the blank first load. Same for an edge function that is cold (see Edge Function errors if the call is failing outright). Moving host without shrinking the bundle (see leaving Lovable hosting) rarely turns a 6-second first visit into a fast one.

When you are done, rerun the throttled reload and, if you want a second opinion on headers and oversized JS, run a free scan of the live URL. The goal is a first screen that appears quickly on a mid-range phone, not a perfect Lighthouse score.

FAQ

Why is the Lovable preview fine but the live site feels slow?

The preview is often on a fast connection, already cached, and sometimes running a dev build. Test the published URL in a private window with caching disabled, ideally throttled to a mid-range phone.

Will a faster host fix this by itself?

A CDN helps, but a 700 KB to several MB JavaScript download still has to be parsed on the user's phone. Hosting changes do not replace a smaller bundle.

Is it safe to remove the big library Lovable added?

Only after you know what still imports it. Remove or replace one dependency at a time, run the production build, and click through the app. A visualizer tells you whether the size actually dropped.

Related guides