source/Core/ViewHelper/JavaScriptRenderer.php
protected function formSnippetsOutput($scripts, $widgetName, $ajaxRequest)
    {
        $preparedScripts = [];
        foreach ($scripts as $script) {
            if ($widgetName && !$ajaxRequest) {
                $sanitizedScript = $this->sanitize($script);
                $script = "WidgetsHandler.registerFunction('$sanitizedScript', '$widgetName');";
            }
            $preparedScripts[] = $script;
        }

        return implode(PHP_EOL, $preparedScripts);
    }
protected function formSnippetsOutput($scripts, $widgetName, $ajaxRequest)
    {
        $preparedScripts = [];
        foreach ($scripts as $script) {
            if ($widgetName && !$ajaxRequest) {
                $sanitizedScript = $this->sanitize($script);
                $script = "WidgetsHandler.registerFunction('$sanitizedScript', '$widgetName');";
            }
            $preparedScripts[] = $script;
        }

        return implode(PHP_EOL, $preparedScripts);
    }
protected function formSnippetsOutput ( $ scripts , $ widgetName , $ ajaxRequest ) { $ preparedScripts = [ ] ; foreach ( $ scripts as $ script ) { if ( $ widgetName && ! $ ajaxRequest ) { $ sanitizedScript = $ this -> sanitize ( $ script ) ; $ script = "WidgetsHandler.registerFunction('$sanitizedScript', '$widgetName');" ; } $ preparedScripts [ ] = $ script ; } return implode ( PHP_EOL , $ preparedScripts ) ; }
Forms how javascript should look like when output.
If varnish is active, javascript should be passed to WidgetsHandler instead of direct call.

@param array  $scripts     Scripts to execute (from add).
@param string $widgetName  Widget name.
@param bool   $ajaxRequest Is ajax request.

@return string
Forms how javascript should look like when output . If varnish is active javascript should be passed to WidgetsHandler instead of direct call .