Caching dynamically added assets by a plugin?

Hi, I’m writing a plugin which injects Vue.js assets to a page.

In the event hook of onPageContentRaw, I managed to add JS files like this:

$this->grav['assets']->addJs($filePath, ['pipeline' => false, 'group' => 'bottom']);

On the initial visit to the page it works fine, but once the page is cached by Grav, these dynamically added assets willl disappear from the HTML (cached).

I could do the same with onPageInitialized instead, to make it work even when the cache is in effect.

However, I’d rather like Grav to cache the page, including these injected assets, since it is not necessary to run the plugin every time when the page is requested.

Any suggestions to achieve this would be much appreciated.

On second thought, I decided to cache the assets by myself.

Using Grav Assets Plugin as a reference, I could implement caching, and now the page looks fine (even if the page cache is in effect).