question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

img-dim is slow and not cached

See original GitHub issue

Hello,

I realized that the img processing is executed multiple times per image - typically, if I add an image to a blog post, it will get processed 3 times (the blog post page itself, the /posts list page, the / list page) + once per tag . I have a site icon processed 22 times per build, for a total of 1721ms according to the 11ty benchmark log.

Caching would be great ; I see a solution in 2 steps :

  • keep an in-memory, transient cache indexed by path: should be easy to do. fill the cache in img-dim, invalidate it when the image changes. pay the cost once per image when starting watch mode, still way better
  • then get to a persistent cache. we could write an image-hashes.json file with the previous hash and generated file path, check it once during watch startup and compare the stored hashes against the actual hashes to invalidate or not the cache entries.

Thoughts ?

Also: it looks like gif2mp4 (which is even slower) is not running if an mp4 file already exists in the source folder (see https://github.com/google/eleventy-high-performance-blog/blob/676789e95149e0c92aee4bb4b89cabc6680db1c0/_11ty/video-gif.js#L32 ). is that intended to act as a basic cache ? in that case it should be if (await exists(join("_site", dest))) { instead of if (await exists(dest)) {

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
cozarkdcommented, Dec 29, 2021

I’m having serious problems with the image processing scripts. My project had an average of 1-2min building time, now it’s +20min. So I can’t use that in netlify or cloudflare pages. Probably need to do it locally in a separate script and store the files.

0reactions
cozarkdcommented, Dec 30, 2021

Did you try running .persistimages.sh after a local build? It should eliminate all slowness.

oh, I thought that file was for remote images, makes sense now. In my use case I had to implement some features but not the full template. Problem solved, thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rendering cached images super slow? - Apple Developer
I assume the problem is that the images are not cached correctly on the device, so when I each second switch the image...
Read more >
Why Hunter is slow? — Hunter 0.23 documentation
Note that Hunter will upload all archives from Cache directory, not only packages build by current local project. As an example here are...
Read more >
Why Your Cached JavaScript Is Still Slow and Incurs ...
Browser cache stores cached files on the end-user's device on disk. Disk access is not granted to the process executing your web application...
Read more >
Slow app load because dotnet.wasm not cached for AOT and ...
wasm is NOT being cached by the browser). Is there something I'm missing in my build configuration that's triggering this behavior? uno-platform.
Read more >
Understanding Cache: How Caching Impacts Site Speed
Caching for Website Optimization. Caching does not make a slow site fast. Caching cuts down the delivery time. The site might seem quicker ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found