Skip to content
Snippets Groups Projects
Commit 246334f3 authored by Steven Wittens's avatar Steven Wittens
Browse files

Don't include drupal.js if there is no JS on the page

parent 94098f7e
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -1363,15 +1363,21 @@ function drupal_get_css($css = NULL) { ...@@ -1363,15 +1363,21 @@ function drupal_get_css($css = NULL) {
* far for $scope is returned. * far for $scope is returned.
*/ */
function drupal_add_js($data = NULL, $type = 'module', $scope = 'header', $defer = FALSE, $cache = TRUE) { function drupal_add_js($data = NULL, $type = 'module', $scope = 'header', $defer = FALSE, $cache = TRUE) {
if (!is_null($data)) {
_drupal_add_js('misc/jquery.js', 'core', 'header', FALSE, $cache);
_drupal_add_js('misc/drupal.js', 'core', 'header', FALSE, $cache);
}
return _drupal_add_js($data, $type, $scope, $defer, $cache);
}
/**
* Helper function for drupal_add_js().
*/
function _drupal_add_js($data, $type, $scope, $defer, $cache) {
static $javascript = array(); static $javascript = array();
if (!isset($javascript[$scope])) { if (!isset($javascript[$scope])) {
$javascript[$scope] = array('core' => array(), 'module' => array(), 'theme' => array(), 'setting' => array(), 'inline' => array()); $javascript[$scope] = array('core' => array(), 'module' => array(), 'theme' => array(), 'setting' => array(), 'inline' => array());
if (empty($javascript['header']['core']['misc/drupal.js'])) {
drupal_add_js('misc/jquery.js', 'core', 'header', FALSE, $cache);
drupal_add_js('misc/drupal.js', 'core', 'header', FALSE, $cache);
}
} }
if (!isset($javascript[$scope][$type])) { if (!isset($javascript[$scope][$type])) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment