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

Woggers’s picture

I 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 ?

r0m4n’s picture

I am also having the same problem. Did you find a solution?

mfer’s picture

Category: bug » support

jQuery 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.

eriktaylor’s picture

I 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.

pingo’s picture

Creating a empty script.js in my theme's directory worked for me as well!

mfer’s picture

Status: Active » Postponed (maintainer needs more info)

Scripts 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.

carn1x’s picture

Category: support » bug
Status: Postponed (maintainer needs more info) » Needs work

Ok 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 :)

sun’s picture

Status: Needs work » Closed (works as designed)

Nope, 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.

JAYBOB’s picture

I 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. :)

satvision83’s picture

I have the same problem with anonymous users. Granting admin theme permission to anonymous didn't helped.

GBain22’s picture

Has 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.

niccottrell’s picture

Status: Closed (works as designed) » Needs review

@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.

Anonymous’s picture

(deleted)

greenmother’s picture

if 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.

haggster’s picture

Did it for me, thank you!

giorgio79’s picture

Version: 6.x-2.0-alpha1 » 7.x-2.x-dev

I am getting this in 7 x as well. Anonymous users dont get jquery ui

heinz.wegener’s picture

I 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.

Morenoid’s picture

Component: User interface » Code
Issue summary: View changes

Had 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.

Morenoid’s picture

Update: This solution is explained in the official documentation here Working with JavaScript and jQuery .

Morenoid’s picture

Status: Needs review » Closed (fixed)
smurfxx’s picture

I'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!