-
Notifications
You must be signed in to change notification settings - Fork 299
Description
This idea was initially formed in #424, and we cannot read files in "save location" synchronously due to the asynchronous nature of the "File Provider".
So a good solution is that we cache them in an internal synchronously readable location and synchronize and update asynchronously.
Now let us think further and document this issue.
We should cache the parsed structured data
Compared to the current reading and parsing content from a userscript file every time.
We should cache the parsed metadata object and the separate userscript code.
It can definitely help us reduce calculations, delays, and energy consumption:
- Investigate extension energy consumption anomalies #557
- manifest.json makes no-op changes on disk very frequently #637
Update the cache only if the original file changes are detected.
Going further, we could even minify the userscript code to improve the efficiency of transmission and parsing.
Note that we should provide an option to disable minify or ship sourcemap for user debugging.
The options worth investing in might be:
- https://www.npmjs.com/package/oxc-minify
oxc
is used as buildrolldown
and will replacerollup
andesbuild
in the future invite
.
We should also refactor @require
to make it pre-bundled and stored in the cache instead of the current way.
Cache location and bundle method
Possible cache locations are the native app container
or browser.storage
.
We could use the bundler native version in swfit or wasm version in browser.