code: public function addJs(string $javascript, array $attributes = [], bool $footer = true) : self
      {
          $meta = new HtmlElement('<script>');
          $meta->addAttribute('type', 'text/javascript');
          $meta->addAttributes($attributes);
  
          if (substr($javascript, -3) == '.js' ||
              substr($javascript, 0, 2) == '//' ||
              substr($javascript, 0, 4) == 'http'
          ) {
              list($path, $hash) = $this->getAssetData($javascript);
              if ($hash) {
                  $meta->addAttribute('name', str_replace(['.js', '.', '/', ':'], ['', '_', '_', '_'], $javascript));
              }
  
              $meta->addAttribute('src', (string) $path);
          } else {
              $meta->setContent($javascript);
          }
  
          if ($footer) {
              $this->footer->add($meta);
          } else {
              $this->head->add($meta);
          }
  
          // add a preload header
          if ($meta->getAttribute('src') && $footer) {
              $preload = new HtmlElement('<link>');
              $preload->addAttributes([
                  'as' => 'script',
                  'href' => $meta->getAttribute('src'),
                  'rel' => 'preload',
              ]);
              $this->head->add($preload);
          }
  
          return $this;
      }
docs: Add Css file inclusion.
  
  @param string $javascript
  @param array $attributes
  @param bool $footer
  
  @return $this|self