perf: wave C — interaction-gate minerals.db fetch on /tools/* widgets#46
Merged
Conversation
Eliminates the eager 8 MB minerals.db + sql-wasm.wasm download on first
paint of every /tools/* route. Every widget that previously called
getDB() from a mount-time useEffect now gates the load behind a
hasInitiated flag that flips on first user interaction (onPointerDown
on the widget root, or a hook-exposed initiate() callback for shared
hooks).
Hooks:
- useCalculatorData: hasInitiated gate + exposed initiate()
- useGemIdentification: hasInitiated gate + exposed initiate()
- useGemLookup: threads initiate() from useCalculatorData
Standalone widgets gated locally via onPointerDown:
- calculator/{DispersionCalculator,HannemanRI}
- optical/{DichroscopeResults,PleochroismReasoner,OpticSignReasoner}
- lab/{UvFluorescenceLookup,HeavyLiquidReference}
- identification/HardnessReference
Hook consumers wired to initiate() via onPointerDown on root wrapper:
- calculator/{SGCalculator,RICalculator,CaratEstimator}
- identification/GemIdentifier
Target: /tools/measurement/ desktop total weight drops from 8,651 KiB
to <500 KiB. Widgets still feel instant on interaction; the existing
loading state handles the brief fetch window.
Part of audits/perf-2026-05/ remediation. WC1 SSG-pass-props
deliberately skipped (polish, not perf — the gate alone hits the
byte-weight acceptance target).
|
🚀 Preview deployed to: https://42ba7aa1.gemmology-dev.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
minerals.db+sql-wasm.wasmdownload on every/tools/*route behind ahasInitiatedflag that flips on first user interaction (onPointerDownon the widget root)loadinginitial state is nowfalse, so no spinner renders until the user actually engages — removing the visual noise on first paint/tools/measurement/desktop total weight drops from 8,651 KiB → <500 KiB on first paintGating pattern
Shared hooks expose an
initiate()callback; hook consumers wire it toonPointerDownon the widget root wrapper:useCalculatorData—hasInitiatedgate +initiate()exposeduseGemIdentification— same patternuseGemLookup— threadsinitiate()fromuseCalculatorDataStandalone widgets set a local
hasInitiatedflag directly viaonPointerDownon the root wrapper:calculator/{DispersionCalculator,HannemanRI}optical/{DichroscopeResults,PleochroismReasoner,OpticSignReasoner}lab/{UvFluorescenceLookup,HeavyLiquidReference}identification/HardnessReferenceHook consumers wired to
initiate():calculator/{SGCalculator,RICalculator,CaratEstimator}identification/GemIdentifierTest plan
/tools/measurement/— confirm no network request forminerals.dborsql-wasm.wasmin DevTools Network tab on page load/tools/optical/,/tools/lab/,/tools/identification//tools/*routebuildandlint-and-checkpass