Skip to content

Optimize site loading performance - #11

Closed
nedcut wants to merge 1 commit into
mainfrom
codex/optimize-site-speed-without-quality-loss
Closed

Optimize site loading performance#11
nedcut wants to merge 1 commit into
mainfrom
codex/optimize-site-speed-without-quality-loss

Conversation

@nedcut

@nedcut nedcut commented Jun 17, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Reduce initial client bundle size and improve perceived load time by avoiding heavy runtime imports and warming network paths for the map.
  • Prevent large utility code (Turf length) from being pulled into the main page graph while keeping identical distance and bounds behavior.
  • Improve first-byte and resource fetch speed for Mapbox and static image assets with connection hints and caching hints.

Description

  • Replaced the Turf length usage in lib/geo.ts with a small in-repo haversine implementation (segmentDistanceMeters and geometryDistanceMeters) used by lineDistanceMeters, coordinateBounds, and routeFeatureCollection so route/bounds math no longer imports Turf length into the page graph.
  • Added preconnect and dns-prefetch link hints for Mapbox origins in app/layout.tsx to warm the network connection before the dynamic map initializes.
  • Added Next.js experimental package import optimization for lucide-react and an HTTP header rule in next.config.mjs to set Cache-Control: public, max-age=31536000, immutable for static image asset paths to enable long-lived caching.
  • Kept runtime behavior and API signatures unchanged so application logic and UI quality are preserved, and left a note that a full Turf split (install/uninstall) could not be performed in this environment.

Testing

  • Ran npm run test (Vitest) and all unit tests passed: 23 files, 192 tests (passed).
  • Ran npm run typecheck && npm run lint && npm run build and the build/typegen completed successfully while ESLint reported one pre-existing warning in lib/hooks/useMembership.ts.
  • Attempting npm run test -- --runInBand failed because Vitest does not accept the Jest --runInBand flag, which is a tooling invocation mismatch rather than a code regression.

Codex Task

@vercel

vercel Bot commented Jun 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lofoten-map Ready Ready Preview, Comment Jun 17, 2026 10:48pm

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6a31a860-f455-42ec-b70d-643e410439bc

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/optimize-site-speed-without-quality-loss

Comment @coderabbitai help to get the list of available commands and usage tips.

@nedcut

nedcut commented Jul 11, 2026

Copy link
Copy Markdown
Owner Author

Closing as superseded. The same goals (drop Turf length from the page graph, Mapbox connection warming, caching) landed via #10 and follow-ups on main. This branch is conflicting and stale.

@nedcut nedcut closed this Jul 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant