@@ -8,7 +8,7 @@ import { useEffect, useState, useRef } from "react";
88import Navbar from "@/components/ui/navbar" ;
99import GameUI from "@/components/gameUI" ;
1010import BannerText from "@/components/bannerText" ;
11- import findLatLongRandom from "@/components/findLatLong" ;
11+ // findLatLongRandom is dynamically imported when needed to avoid loading Google Maps API on page load
1212import Link from "next/link" ;
1313import MultiplayerHome from "@/components/multiplayerHome" ;
1414import AccountModal from "@/components/accountModal" ;
@@ -2091,12 +2091,18 @@ export default function Home({ }) {
20912091 options = options . sort ( ( ) => Math . random ( ) - 0.5 )
20922092 setOtherOptions ( options )
20932093 } else {
2094- function defaultMethod ( ) {
2095- console . log ( "[PERF] loadLocation: Calling findLatLongRandom" ) ;
2094+ async function defaultMethod ( ) {
2095+ console . log ( "[PERF] loadLocation: Calling findLatLongRandom (dynamic import) " ) ;
20962096 const startTime = performance . now ( ) ;
2097- findLatLongRandom ( gameOptions ) . then ( ( latLong ) => {
2097+ try {
2098+ const { default : findLatLongRandom } = await import ( "@/components/findLatLong" ) ;
2099+ console . log ( `[PERF] findLatLong module loaded in ${ ( performance . now ( ) - startTime ) . toFixed ( 2 ) } ms` ) ;
2100+ const latLong = await findLatLongRandom ( gameOptions ) ;
20982101 setLatLong ( latLong ) ;
2099- } ) ;
2102+ } catch ( err ) {
2103+ console . error ( "[ERROR] Failed to load location:" , err ) ;
2104+ toast ( text ( "errorLoadingMap" ) , { type : 'error' } ) ;
2105+ }
21002106 }
21012107 function fetchMethod ( ) {
21022108 //gameOptions.countryMap && gameOptions.offical
@@ -2166,7 +2172,7 @@ export default function Home({ }) {
21662172 }
21672173 defaultMethod ( )
21682174 }
2169- } ) . catch ( ( e ) => {
2175+ } ) . catch ( ( ) => {
21702176 toast ( text ( "errorLoadingMap" ) , { type : 'error' } )
21712177 defaultMethod ( )
21722178 } ) ;
@@ -2373,7 +2379,7 @@ export default function Home({ }) {
23732379 msUserSelect : 'none' ,
23742380 pointerEvents : 'none' ,
23752381 } } >
2376- < NextImage . default src = { './street2christmas.jpg ' }
2382+ < NextImage . default src = { './street2.webp ' }
23772383 draggable = { false }
23782384 width = { 1920 }
23792385 height = { 1080 }
@@ -2422,7 +2428,7 @@ export default function Home({ }) {
24222428
24232429 { /* Loading overlay - covers iframe with background image to prevent white flicker */ }
24242430 < div className = { `loading-overlay ${ loading ? 'loading-overlay--visible' : '' } ` } >
2425- < NextImage . default src = { './street2christmas.jpg ' }
2431+ < NextImage . default src = { './street2.webp ' }
24262432 draggable = { false }
24272433 width = { 1920 }
24282434 height = { 1080 }
0 commit comments