Efficiently\Larasset\Asset::javascriptIncludeTag PHP Method

javascriptIncludeTag() public method

Returns an HTML script tag for the sources and attributes specified as arguments.
public javascriptIncludeTag ( array | string $sources = "application", array $attributes = [] ) : string
$sources array | string default "application"
$attributes array HTML attributes
return string
    public function javascriptIncludeTag($sources = "application", $attributes = [])
    {
        // E.g. javascript_include_tag('app'); => app-9fcd9b50e5cb047af35d3c5a4b55f73f.js
        $args = func_get_args();
        if (is_array(last($args))) {
            $attributes = array_pop($args);
        } else {
            $attributes = [];
        }
        $sources = is_array($sources) ? $sources : $args;
        if (empty($sources)) {
            $sources = ["application"];
        }
        $assetsOptions = ['host' => array_pull($attributes, 'host', $this->assetsHost)];
        $defaults = ['type' => 'text/javascript'];
        $attributes = $attributes + $defaults;
        $javascript_tags = [];
        foreach ((array) $sources as $source) {
            $sourceName = "{$source}.js";
            $javascript_tags[] = app('html')->script($this->assetPath($sourceName, $assetsOptions), $attributes);
        }
        return implode($javascript_tags);
    }