5

jquery.cookie.js is loaded only for authenticated users and i cannot really figure out why. The page caching is disabled.

Any thoughts?

13

The jQuery.cookie library is not always included, it depends the user state and the visiting page.

For example, the login form includes this library by attaching (#attached) it to the form.

What you could do is include it yourself in a custom module or in your theme.

// hook_init()
function YOURMODULE_init() 
{
     drupal_add_library('system', 'jquery.cookie');
}

// or in theme preprocess
function YOURTHEME_preprocess_page(&$vars)
{
     drupal_add_library('system', 'jquery.cookie');
}
  • Well the script is loaded for authenticated users from jQuery update module, i could load it explicitly in a hook_init but that looks weird – Pan Chrono Nov 1 '13 at 14:54
  • Accepted the answer because drupal_add_library('system', 'jquery.cookie'); loads the script only once, even if you are authenticated, so thats OK – Pan Chrono Nov 1 '13 at 15:11
  • 1
    Yes, thats handy when using drupal_add_library, it will be only include the library once, even if you called it multiple times. – Mike Vranckx Nov 1 '13 at 15:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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