Set field asset with __construct?

Here is a part of a field. I set the $assets array to contain a css file. It works when using the static public variable. It does not work when I try to do the same thing with the __construct. Any idea why?

class MyField extends TagsField {
  static public $assets = array(
    'css' => array(

  public function __construct() {
    self::$assets = array(
      'css' => array(

What I really want to do is to have an if statement. If a config value is something, don’t load the css file at all.

I guess it has to do with static variables or some PHP that prevents my construct from setting or overriding the set variable?

I think the Panel loads all plugin assets at runtime, independent of whether or not the constructor is actually called.

Then there is no possible way around this issue then?

It would probably be possible to have an if statement around the whole field, or having two fields and only register one of them. Both my suggestions are really bad, but they would probably work.

Maybe add a new registry set where it’s possible to register a field css not bound to a field.

$kirby->set('field::css', 'path/to/style.css');

Because a panel page is more than a field it would probably make more sense to do it like this:

$kirby->set('panelPage::css', 'path/to/style.css');
$kirby->set('panelPage::js', 'path/to/script.js');

Thinking out loud.