mirror of
https://github.com/jcreek/LivingDexTracker.git
synced 2026-09-18 19:42:04 +00:00
perf(sprites): serve grid-sized thumbnails from an immutable URL space
Every grid cell downloaded the full detail sprite. Generate a smaller /sprites-grid/v1/ set at build time and let the grid ask for those first, falling back through the existing detail URLs when a thumbnail is missing so detail resolution is unchanged. The new prefix is versioned, so it can be cached forever, and the service worker recognises it alongside the other sprite roots. The placeholder is now an empty box rather than a spinner: a thousand spinners cost layout work and announced nothing useful.
This commit is contained in:
@@ -46,3 +46,14 @@ export function resolveSpriteUrl(
|
||||
if (/^female\b/i.test(form)) root += '/female';
|
||||
return `${root}/${key}.webp`;
|
||||
}
|
||||
|
||||
/** Grid assets use a separate immutable URL space; detail resolution is unchanged. */
|
||||
export function resolveGridSpriteUrl(
|
||||
entry: { pokedexNumber: number; form?: string; spriteKey?: string },
|
||||
shiny: boolean
|
||||
): string {
|
||||
return resolveSpriteUrl(entry, shiny, true).replace(
|
||||
'/sprites-small/home/',
|
||||
'/sprites-grid/v1/home/'
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user