- Issue created by @fathershawn
- Merge request !23Issue #3486968 by fathershawn: Return ajax_page_state['libraries'] via a header β (Open) created by fathershawn
We currently follow the existing pattern in core in which drupalSettings.ajaxPageState.libraries
is returned with each request as a query parameter. The works to keep the asset libraries in sync. However, in core only automated processes see these urls. With HTMX if hx-push-url is used with true the url of the request is pushed to the location bar.
Given the work done in π Compress ajax_page_state Fixed , move the transmission of page state from a query parameter to a header. The compression should keep this string well within the 8K bytes (8K UTF-8 characters) limit imposed by the most common web servers.
Refactor htmxDrupalPageState
to place drupalSettings.ajaxPageState.libraries
in an HX-Page-State
header.
Refactor HtmxResponseAttachmentsProcessor::processAssetLibraries
to begin with code to process the header. Just before this method is called the parent runs
$ajax_page_state = $this->requestStack->getCurrentRequest()->get('ajax_page_state');
$assets->setAlreadyLoadedLibraries(isset($ajax_page_state) ? explode(',', $ajax_page_state['libraries']) : []);
Active
1.3
Drupal Code