You are here

pace.module in PACE - Page load progress bar 8

Same filename and directory in other branches
  1. 7 pace.module
  2. 2.0.x pace.module

Loads PACE js.

File

pace.module
View source
<?php

/**
 * @file
 * Loads PACE js.
 */
use Symfony\Component\HttpFoundation\Request;
use Symfony\Cmf\Component\Routing\RouteObjectInterface;

/**
 * Implements template_preprocess_html().
 */
function pace_preprocess_html(&$variables) {

  // Check if PACE is disabled for admin pages and don't load it.
  if (!\Drupal::config('pace.settings')
    ->get('pace_load_on_admin_enabled')) {
    $is_admin = \Drupal::service('router.admin_context')
      ->isAdminRoute();
    if (!$is_admin) {
      load_pace($variables);
    }
  }
  else {
    load_pace($variables);
  }
}
function load_pace(&$variables) {
  $variables['#attached']['library'][] = 'pace/pace';
  $variables['#attached']['library'][] = 'pace/' . \Drupal::config('pace.settings')
    ->get('pace_color') . '-' . \Drupal::config('pace.settings')
    ->get('pace_theme');
}

Functions