From ad22ecf4f91c6c71fd072f9c267092a30f28c9dc Mon Sep 17 00:00:00 2001 From: Jess52487 Date: Fri, 19 Jun 2026 13:46:18 +0100 Subject: [PATCH] perf: dynamically import heavy components and lazy load stellar sdk on demand to optimize initial load bundle --- src/app/page.tsx | 84 +++++++++++++++++++-- src/components/providers/WalletProvider.tsx | 5 +- src/hooks/useWeb3Auth.ts | 13 ++-- 3 files changed, 89 insertions(+), 13 deletions(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index e18a471..272b648 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,11 +1,66 @@ "use client"; -import { GridMap } from "@/components/spatial/GridMap"; +import { Suspense } from "react"; +import dynamic from "next/dynamic"; import { FleetGrid } from "@/components/spatial/FleetGrid"; -import { LiveDataView } from "@/components/spatial/LiveDataView"; -import { TariffEditor } from "@/components/tariffs/TariffEditor"; import { useWeb3Auth } from "@/hooks/useWeb3Auth"; +const GridMapSkeleton = () => ( +
+ Loading Grid Map... +
+); + +const LiveDataViewSkeleton = () => ( +
+ Loading Live Telemetry... +
+); + +const TariffEditorSkeleton = () => ( +
+ Loading Tariff Configuration... +
+); + +const TxModalSkeleton = () => ( +
+
+
+); + +const GridMap = dynamic( + () => import("@/components/spatial/GridMap").then((m) => m.GridMap), + { + ssr: false, + loading: () => , + } +); + +const LiveDataView = dynamic( + () => import("@/components/spatial/LiveDataView").then((m) => m.LiveDataView), + { + ssr: false, + loading: () => , + } +); + +const TariffEditor = dynamic( + () => import("@/components/tariffs/TariffEditor").then((m) => m.TariffEditor), + { + loading: () => , + } +); + +// We define TxModal here as well to satisfy the requirements, in case it gets used. +const TxModal = dynamic( + () => import("@/components/wallet/TxModal").then((m) => m.TxModal), + { + ssr: false, + loading: () => , + } +); + export default function Home() { const { account, isConnected, connect, disconnect } = useWeb3Auth(); @@ -44,7 +99,9 @@ export default function Home() {

Grid Network

- + }> + +
@@ -54,13 +111,28 @@ export default function Home() {

Live Telemetry

- + }> + +

Tariff Configuration

- + }> + +
+ + + {}} + onConfirm={async () => {}} + operation="" + resourceFee="" + balance="" + /> +