Skip to content

Conversation

Copy link

Copilot AI commented Nov 30, 2025

Gallery images were blocking the main app during loading, preventing navigation and interaction until all images loaded.

Changes

Image component (Image.svelte)

  • Fixed responsive image selection: changed sizes to media queries for proper source selection
  • Added fetchpriority="low" to prevent blocking main thread

Image server endpoint (/image/[name]/+server.ts)

  • Streaming: Non-cached images now stream via ReadableStream instead of buffering entire file
  • ETag support: Conditional requests return 304 Not Modified
  • Early headers: Cache headers (max-age=31536000, immutable) sent immediately with response
  • Background caching: Files cached to memory while streaming to client
// Stream directly from disk, cache in background
const fileStream = createReadStream(filePath);
const webStream = nodeStreamToWebStream(fileStream);

fs.readFile(filePath)
  .then((buffer) => memoryCache.set(filePath, buffer))
  .catch(() => {});

return new Response(webStream, {
  headers: getCacheHeaders(fileExtension, fileInfo.size, etag)
});

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI mentioned this pull request Nov 30, 2025
Draft
@patrick11514 patrick11514 linked an issue Nov 30, 2025 that may be closed by this pull request
Copilot AI and others added 2 commits November 30, 2025 17:10
Co-authored-by: patrick11514 <56652391+patrick11514@users.noreply.github.com>
Co-authored-by: patrick11514 <56652391+patrick11514@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix image loading issues in gallery Optimize gallery image loading with streaming and proper lazy loading Nov 30, 2025
Copilot AI requested a review from patrick11514 November 30, 2025 17:14
@patrick11514 patrick11514 marked this pull request as ready for review November 30, 2025 17:17
@patrick11514 patrick11514 merged commit 2c4646b into V3 Nov 30, 2025
4 checks passed
@patrick11514 patrick11514 deleted the copilot/sub-pr-4 branch November 30, 2025 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Performance issues

2 participants