Skip to content

Implement userscripts cache #817

@ACTCD

Description

@ACTCD

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:

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:

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.

Sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions