Where to use the js and css helper in plugin?

I have to load some “global” css and js to my plugin - what means that it will be used by all plugin templates.

I thought maybe it would be a good idea to include this in the index.php, but…

<?=css([
    '/media/plugins/my/plugin/css/w.css',
    '/media/plugins/my/plugin/css/all.css',
])?>
<?=js([
    '/media/plugins/my/plugin/js/a.min.js',
    '/media/plugins/my/plugin/js/b.js',
])?>

I get an error on my admin panel: https://page.test/panel/site as bad side effect.

  • What works is: If I remove the code from index.php and insert it into each template. But that creates a lot of redundancy because it has to be in all templates.

  • I have tried to put the code in a snippet, and include this in all my plugin templates, but then css and js code is ignored. Why is that?

  • Where is the valid place to include such global assets in a plugin?

  • Normally the header would be the place where I would integrate this. Does Kirby offer the possibility to induce plugin js and css in the global header?

Okay: I try index.css and index.js beside index.php… perhaps that works

there is no global helper to register custom/js and CSS from a plugin. the index.js and index.css files are intended to be loaded in the panel only.