Bolt\Asset\Widget\Queue::addDeferredJavaScript PHP Method

addDeferredJavaScript() protected method

Insert a snippet of Javascript to fetch the actual widget's contents.
protected addDeferredJavaScript ( Bolt\Asset\Widget\WidgetAssetInterface $widget, Response $response )
$widget Bolt\Asset\Widget\WidgetAssetInterface
$response Symfony\Component\HttpFoundation\Response
    protected function addDeferredJavaScript(WidgetAssetInterface $widget, Response $response)
    {
        if ($this->deferAdded) {
            return;
        }
        $javaScript = $this->render->render('widgetjavascript.twig', ['widget' => $widget]);
        $snippet = (new Snippet())->setLocation(Target::AFTER_BODY_JS)->setCallback((string) $javaScript);
        $this->deferAdded = true;
        $this->injector->inject($snippet, Target::AFTER_BODY_JS, $response);
    }