At now module each time loads all Site Settings to memory on hook_tokens() (even if we need only one value) via string:

      $settings = $site_settings->loadAll();

This is not so good behavior, because site can contain very long list of settings, but in each page we need only small part of them, and spend resources & memory for load a lot of unneeded data, like variables in Drupal 7.x

So will be good to implement loading Site Settings only on demand.

Comments

Murz created an issue. See original summary.

scott_euser’s picture

The idea is to keep it very simple to use in any template without having to do extra work. I'd be happy to accept a patch for a option allowing the editor to turn this behaviour off, but switching it to off by default would be a breaking change for any active sites.

Ie, at https://cgit.drupalcode.org/site_settings/tree/site_settings.module#n70

/**
 * Implements hook_preprocess().
 */
function site_settings_preprocess(&$variables) {

  // Get template key. We give the admin control over this in case it conflicts
  // with a particular module.
  $config = \Drupal::config('site_settings.config');
  $template_key = $config->get('template_key');

  // Load the site settings into the specified key.
  $site_settings = \Drupal::service('site_settings.loader');
  $variables[$template_key] = $site_settings->loadAll();
}

We could instead put that in a conditional, having it on by default but an option to turn it off here https://cgit.drupalcode.org/site_settings/tree/src/Form/SiteSettingsConf....

scott_euser’s picture

Status: Active » Closed (won't fix)

Closing this for now unless someone wants to offer to add this as a setting in the module configuration page.