src/Asset/Asset.php
public function attributes(array $attributes): AssetInterface
    {
        if (is_null($this->getType())) {
            throw new AssetException('The asset must have a type.');
        }

        $hook = 'script' === $this->getType() ? 'script_loader_tag' : 'style_loader_tag';
        $key = strtolower(trim($this->getHandle()));
        $attributes = $this->html->attributes($attributes);

        $this->filter->add($hook, function ($tag, $handle) use ($attributes, $key) {
            if ($key !== $handle) {
                return $tag;
            }

            return preg_replace('/(src|href)(.+>)/', $attributes.'$1$2', $tag);
        });

        return $this;
    }
public function attributes(array $attributes): AssetInterface
    {
        if (is_null($this->getType())) {
            throw new AssetException('The asset must have a type.');
        }

        $hook = 'script' === $this->getType() ? 'script_loader_tag' : 'style_loader_tag';
        $key = strtolower(trim($this->getHandle()));
        $attributes = $this->html->attributes($attributes);

        $this->filter->add($hook, function ($tag, $handle) use ($attributes, $key) {
            if ($key !== $handle) {
                return $tag;
            }

            return preg_replace('/(src|href)(.+>)/', $attributes.'$1$2', $tag);
        });

        return $this;
    }
public function attributes ( array $ attributes ) : AssetInterface { if ( is_null ( $ this -> getType ( ) ) ) { throw new AssetException ( 'The asset must have a type.' ) ; } $ hook = 'script' === $ this -> getType ( ) ? 'script_loader_tag' : 'style_loader_tag' ; $ key = strtolower ( trim ( $ this -> getHandle ( ) ) ) ; $ attributes = $ this -> html -> attributes ( $ attributes ) ; $ this -> filter -> add ( $ hook , function ( $ tag , $ handle ) use ( $ attributes , $ key ) { if ( $ key !== $ handle ) { return $ tag ; } return preg_replace ( '/(src|href)(.+>)/' , $ attributes . '$1$2' , $ tag ) ; } ) ; return $ this ; }
Add asset attributes.

@param array $attributes

@throws AssetException

@return AssetInterface
Add asset attributes .