Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

perf: Stats, History, Library, Muscles, Settings, check-in and the routine editor load on demand

Duarte Santose8b4ba2768c8
diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx
index 3dbecc2d8..3e161654a 100644
--- a/frontend/src/App.jsx
+++ b/frontend/src/App.jsx
@@ -42,15 +42,8 @@ import Login from './views/Login.jsx'
import MobileOnboarding from './views/MobileOnboarding.jsx'
import PermissionSteps from './views/PermissionSteps.jsx'
import Home from './views/Home.jsx'
-import CheckIn from './views/CheckIn.jsx'
import Plan from './views/Plan.jsx'
-import RoutineEdit from './views/RoutineEdit.jsx'
import Workout from './views/Workout.jsx'
-import Stats from './views/Stats.jsx'
-import History from './views/History.jsx'
-import Library from './views/Library.jsx'
-import Muscles from './views/Muscles.jsx'
-import { SettingsRoute } from './views/Settings.jsx'
// Screens most sessions never open (the Coach, the admin dashboard, photos, measurements, the
// balance check) are their own chunks rather than part of the code every start parses: ~200 KB
@@ -74,6 +67,15 @@ const CoachIntake = lazyView(() => import('./views/CoachIntake.jsx'))
const CoachSetup = lazyView(() => import('./views/CoachSetup.jsx'))
const StructuralBalance = lazyView(() => import('./views/StructuralBalance.jsx'))
const ProgressPhotos = lazyView(() => import('./views/ProgressPhotos.jsx'))
+// The tabs and screens past Home (Stats, History, the Library, Settings, ...) as well: a start
+// only needs Home, and these are fetched right behind it the same way.
+const CheckIn = lazyView(() => import('./views/CheckIn.jsx'))
+const RoutineEdit = lazyView(() => import('./views/RoutineEdit.jsx'))
+const Stats = lazyView(() => import('./views/Stats.jsx'))
+const History = lazyView(() => import('./views/History.jsx'))
+const Library = lazyView(() => import('./views/Library.jsx'))
+const Muscles = lazyView(() => import('./views/Muscles.jsx'))
+const SettingsRoute = lazyView(() => import('./views/Settings.jsx').then(m => ({ default: m.SettingsRoute })))
let viewsPrefetched = false
const prefetchViews = () => {
if (viewsPrefetched) return
diff --git a/frontend/src/App.swipe-preview.test.jsx b/frontend/src/App.swipe-preview.test.jsx
index 10185dadb..c971bb214 100644
--- a/frontend/src/App.swipe-preview.test.jsx
+++ b/frontend/src/App.swipe-preview.test.jsx
@@ -38,6 +38,9 @@ beforeEach(async () => {
scrolls = []
window.scrollTo = vi.fn((x, y) => { scrolls.push([x, y]); Object.defineProperty(window, 'scrollY', { configurable: true, value: y }) })
await act(async () => { root.render(<App />) })
+ // Settings is its own chunk (App.jsx lazyView); the app fetches it right after the start.
+ await vi.waitFor(() => expect(document.querySelector('#app [data-back], #app .page-in > *')).not.toBeNull())
+ await act(async () => {})
})
afterEach(() => {
act(() => root.unmount())