Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
jquery is not being dumped for anonymous users. When logged in as an administrator though, jquery does indeed get loaded and works fine.
When viewing site as anonymous though - jquery (and $scripts) never get rendered on any template pages?
Anyone know whats going on?
Comments
Comment #1
Woggers CreditAttribution: Woggers commentedI should add that this Drupal deployment is running on v6.6 which goes back to 2008. Client refuses to update to latest version. No idea why. I'm concerned this might be a bug w/ 6.6 or earlier ?
Comment #2
r0m4n CreditAttribution: r0m4n commentedI am also having the same problem. Did you find a solution?
Comment #3
mfer CreditAttribution: mfer commentedjQuery Update works by altering the theme registry and sticking jquery_update_preprocess_page() in as the last hook_preprocess_page() function called. If something else is interfering with this behavior jQuery Update will not work. Is that happening?
This is the only way to effect this change in Drupal 6. Drupal 7 has a new hook we can use to avoid this process.
Comment #4
eriktaylor CreditAttribution: eriktaylor commentedI had the same problem today, in fact. I had no problems with scripts not loading until I would log out and view the site as an anonymous visitor. In my situation, I did not include any script files in my theme's .info. Keep in mind that Drupal 6.x by default includes scripts[] = script.js unless you override it in your .info file. I created an empty script.js file in my theme's directory and this seems to have solved the problem. jQuery and drupal.js both loaded fine after this change. This behavior seems a little odd to me, but it was easy enough to fix.
Comment #5
pingo CreditAttribution: pingo commentedCreating a empty script.js in my theme's directory worked for me as well!
Comment #6
mfer CreditAttribution: mfer commentedScripts are only added to a page if they are needed. If nothing calls drupal_add_js() the scripts will not be added. This includes jquery.js and drupal.js. The the scripts only being added for authenticated users by the code?
There really is not enough detail to diagnose what's going on here.
Comment #7
carn1x CreditAttribution: carn1x commentedOk I had the same issue, here is the entirety of my problem:
I'm running jQuery in a block in order to use per-page visibility settings that blocks provide.
This code generates errors if I am not logged in as $scripts is not being loaded for anonymous users, which includes jQuery provided by the jQuery Update module.
If I add a blank js file to my theme.info file, then $scripts outputs for anonymous users, and also includes jQuery allowing my jQuery in a block to run without error.
I'm guessing that jQuery is only running as admin_menu is requiring it, which only runs when a user is logged in.
In my opinion, either jQuery Update needs to run jQuery for anonymous users regardless of other modules, or provide this control in the options.
Thanks for the above people who found the fix :)
Comment #8
sunNope, it would be wrong to load JavaScript for pages that don't need it. If you need jQuery, then you have to properly load it.
Comment #9
JAYBOB CreditAttribution: JAYBOB commentedI simply granted admin theme permission to anonymous and it solved this problem.
jQuery update didn't work with admin nor anon and therefore I've added latest jQuery and UI from theme using alter().
This way I can use theme roller and be able to provide eye-candy for every user. :)
Comment #10
satvision83 CreditAttribution: satvision83 commentedI have the same problem with anonymous users. Granting admin theme permission to anonymous didn't helped.
Comment #11
GBain22 CreditAttribution: GBain22 commentedHas any found a bulletproof solution for this? I'm having the same issue using Jquery Update. I have tried using the Google CDN and the "None" option but my Jquery does not get updated for Anonymous users.
I've tried the blank script.js and included it in my .info file but this changed nothing.
Comment #12
niccottrell CreditAttribution: niccottrell commented@sun Can you please advise the proper way to load it? Maybe provide a link to the manual when closing this? As of today the "Read documentation" link in the jquery_update project is broken and so hard to look up things.
Comment #13
Anonymous (not verified) CreditAttribution: Anonymous commented(deleted)
Comment #14
greenmother CreditAttribution: greenmother commentedif you use UI in your theme and have this problem, try to add in template.php
drupal_add_library('system', 'ui');
in hook_preprocess_html.
it's helps me.
Comment #15
haggster CreditAttribution: haggster commentedDid it for me, thank you!
Comment #16
giorgio79 CreditAttribution: giorgio79 commentedI am getting this in 7 x as well. Anonymous users dont get jquery ui
Comment #17
heinz.wegener CreditAttribution: heinz.wegener commentedI was having a similar issue where jquery files weren't loading for anonymous users.
I had turned on block caching in the interest of performance, but turning off block caching is what solved my problem. Anonymous users were seeing cached blocks, including the block that contained my form with date_popup fields. Since the content being served was cached, Drupal didn't know to include some crucial jquery files, and the popup calendars weren't working. Hope that helps somebody.
Comment #18
Morenoid CreditAttribution: Morenoid commentedHad the same problem. I solved putting together the solutions suggested here. I use JQuery Update module and Zen Theme so I already have script.js in the my-theme.info file. I just added
drupal_add_library('system', 'ui');
as greenmother said in my my-theme_preprocess_html(...) function in template.php.Comment #19
Morenoid CreditAttribution: Morenoid commentedUpdate: This solution is explained in the official documentation here Working with JavaScript and jQuery .
Comment #20
Morenoid CreditAttribution: Morenoid commentedComment #21
smurfxx CreditAttribution: smurfxx commentedI'm sorry if I reopen this topic but in the theme that I use, the multipurpose theme, there isn't a function preprocess_html.
Can you please help me?
Thanks!