Drupal adds these three files the first time drupal_add_js() is called with anything in the $data argument.

In Drupal 6, we didn't call drupal_add_js() by default, at least not on visitor-facing pages.

In Drupal 7 and 8, this now happens on every request, because of the ajaxPageState setting added in drupal_theme_initialize() - note that setting is added even if ajax.js is never loaded on the request.

A lot of sites don't necessarily add any other jQuery on visitor-facing pages, so we could save a lot just by ensuring that we don't load any js by default unless absolutely necessary.

Here's an only-very-slightly tested patch that does this - when you get a setting the first time, it add the default settings, when you get something other than a setting the first time, it adds the files.

CommentFileSizeAuthor
drupal_add_js_setting.patch1.77 KBcatch
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nod_’s picture

Issue tags: +JavaScript clean-up

tag.

jcisio’s picture

Status: Needs review » Needs work

The settings requires jQuery and causes a JS error because the library is not included.

jcisio’s picture

Also, it requires drupal.js, too. One approach that I use is using a simple object to store settings (like this - that change is ugly, though).

sun’s picture