See Added methods to avoid loading jQuery and related JavaScript libraries on all pages when they are not needed.
Starting from Drupal 7.36, Drupal could not load jQuery to the page.
If you are adding JavaScript from your module, it means you are doing one of the following:
In both the cases, you can force Drupal to load jQuery.
drupal_add_js('path/to/some/javascript-library-needing-jquery.js', array('requires_jquery' => TRUE));
$build['#attached']['js'][] = array(
drupal_get_path('module', 'mymodule') . '/javascript-library-needing-jquery.js' => array('requires_jquery' => TRUE)
);
Notice that, normally, calling drupal_add_js()
or adding $build['#attached']['js']
is sufficient for making Drupal load jQuery, but if another module set 'requires_jquery'
to FALSE
, or if the settings.php file contains a $conf['javascript_always_use_jquery'] = FALSE;
line, then jQuery will not be loaded. Only when your module is setting 'requires_jquery'
to TRUE
with one of the methods I described, you are sure the jQuery library is loaded from Drupal.
Notice that, in either cases, if none of the modules (or the theme) is adding JavaScript code to the page through drupal_add_js()
, #attached
, or the scripts directive in a .info file, Drupal will not load the jQuery library. This means that, if you are hard-coding the link to an external JavaScript file in a template file, Drupal will not know JavaScript code is being used, and it will not load the jQuery library found in the misc directory of the Drupal root directory.