// Create a new HtmlResponse. Ensure the CSS and (non-bottom) JS is sent
// before the HTML they're associated with.
// @see \Drupal\Core\Render\HtmlResponseSubscriber
// @see template_preprocess_html()
$js_bottom_placeholder = '<nojs-bigpipe-placeholder-scripts-bottom-placeholder token="' . Crypt::
randomBytesBase64(55
) . '">';
$html_response =
new HtmlResponse();
$html_response->
setContent([ '#markup' => BigPipeMarkup::
create($js_bottom_placeholder),
'#attached' =>
[ 'drupalSettings' =>
$cumulative_assets->
getSettings(),
'library' =>
$cumulative_assets->
getAlreadyLoadedLibraries(),
'html_response_attachment_placeholders' =>
[ 'scripts_bottom' =>
$js_bottom_placeholder,
],
],
]);
$html_response->
getCacheableMetadata()->
setCacheMaxAge(0
);
// Push a fake request with the asset libraries loaded so far and dispatch
// KernelEvents::RESPONSE event. This results in the attachments for the
// HTML response being processed by HtmlResponseAttachmentsProcessor and
// hence the HTML to load the bottom JavaScript can be rendered.