I have face this problem often in my drupal site. The drupal.js file is loading before jquery.js, so i get the "uncaught jQuery is not defined" error.

I have been using memcached also in my site.

But I can fix the error by the following steps

  1. Restart memcached
  2. Restart Apache
  3. Cache clear
  4. Run the cron

After doing the steps the jQuery is loading properly.

Now, i want to know the reason why the drupal.js loading before jquery.js?

FYI : This is happening, When I enable/disable any modules/features through UI


3 Answers 3


May be because of cache that might cause

  1. Check if you installed jquery_update module

  2. in themes info check if there you have declared jquery

    3.check if in any module hook_init() you are adding your js with weight.

if you install jquery update module you dont need to add jquery plugin in info file

if you have any clarification regarding the js weight and so on read the following links will be helpful




Use hook_js_alter see the below example code.

function MODULENAME_js_alter(&$js) {
drupal_add_js('mise/drupal.js', 'external');
drupal_add_js('mise/jquery.js', 'external');    
  • It is not a drupal normal behavior, but something strange in my site. I need to find out that. your solutions is a temporary one.
    – Leopathu
    Feb 18, 2015 at 7:38
  • 4
    That's the problem @Leopathu: it's not normal behaviour, but we don't have access to your code, so it's pretty difficult to suggest what might be going wrong. However...check your codebase for hook_js_alter() implementations, maybe some rogue code is doing something it shouldn't. Also temporarily disable aggregation and any modules (e.g. advagg) that change that process. Check theme preprocesses for the html template, try with a different theme to see if the problem persists, and so on
    – Clive
    Feb 18, 2015 at 11:33

Thanks @Clive, you comment help more to find out the issue.

In my case, we have used the drupal_add_js outside of the functions/hooks without any conditions as the following code,


// Adds the custom css file into the module.
$module_path = drupal_get_path('module', 'kf_book_quiz');
drupal_add_js($module_path . '/kf_book_quiz.js');
drupal_add_css($module_path . '/kf_book_quiz.css');
drupal_add_css($module_path . '/kf_book_quiz_rwd.css');

 * Implements hook_init()
function kf_book_quiz_init() {


It is not a proper way to add the js into module. This would break the js queue structure. We should add js only where it is needed, we could use hook_preprocess_page to add js for needed place with conditions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.