6

I am working on a Drupal site on which a functionality breaks because the value of Drupal.settings.ajaxPageState.js gets reset to an empty array instead of an object containing the list of js files.

So I want to know what exactly is the use of this ajaxPageState object

0

The ajaxPageState object is used to collect already loaded theme assets (css, js files in Drupal 7, libraries in Drupal 8 and later) and pass that on to Drupal when doing AJAX requests, so that assets that have already been loaded are not loaded again. It also holds information about the theme currently in use, so that rendered results of AJAX requests can use the same theme.

See where it's used in Drupal 7:
https://git.drupalcode.org/project/drupal/-/blob/7.x/misc/ajax.js#L348

And in the current Drupal 9:
https://git.drupalcode.org/project/drupal/-/blob/9.3.x/core/misc/ajax.es6.js#L783

Resetting ajaxPageState to an empty object or array will definitively have surprising effects on all features that rely on AJAX requests, as it basically means a lack of context for the theme logic on the server side.

1
  • I know, that's a bit late to help the original poster, but given that there doesn't seem to be another answer to this on Drupal Answers, I figured it's worth adding one.
    – berliner
    Nov 20 at 23:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.