ffmpeg.wasm icon indicating copy to clipboard operation
ffmpeg.wasm copied to clipboard

Store WASM file in localStorage

Open YugankSingh opened this issue 2 years ago • 2 comments

The Library is really good, but the only thing is that it takes very long to load the library cause it is humungous. Which is sometimes frustrating as a developer and will obviously be frustrating to the consumer.

The Idea I have is that we can store a compressed WASM file and then store it in the localStorage. Then when the load function is called and if the corePath is the same we can directly get the file from localStorage and inject it. We can offer a flag like cacheLocalStorage: boolean, to configure this. If the WASM file is not there in localStorage we can download it. We can do similar stuff with worker.js and core.js files, which are much smaller than the WASM file. We should also check the limit of localStorage to avoid errors.

YugankSingh avatar Jun 04 '22 05:06 YugankSingh

As far i know localStorage limit per site is 5mb, so i guess it might be hard to compress it under 5mb

0x6DD8 avatar Jun 19 '22 00:06 0x6DD8

What about IndexedDB?

simon300000 avatar Jul 12 '22 16:07 simon300000

What about IndexedDB?

That's what I was thinking, but I went into my code today and can't seem to figure out how to cache it.

EladKarni avatar Dec 22 '22 13:12 EladKarni

What about IndexedDB?

That's what I was thinking, but I went into my code today and can't seem to figure out how to cache it.

Ya, it's doable with IndexedDB. I made it in my repo, you can reference it from: https://github.com/iketiunn/webm-to-mp4/blob/main/src/App.tsx#L8-L24

iketiunn avatar Apr 07 '23 09:04 iketiunn