jQuery not Loading for "Anonymous" Users For Drupal 7, a jQuery will not load for "anonymous" users on any template pages. But when I log in as an administrator it loads. It's similar to this issue: http://drupal.org/node/802432, but nothing I tried has worked. The only way I could get the jQuery to load was by giving the user access to the administration menu, which I do not want to do.

I have the following code in the preprocess_node function of the template.php file. 

if ($variables['view_mode'] == 'full') {
$node =&amp; $variables['node'];
if ($node-&gt;type == 'page') {
  $path = drupal_get_path('theme', 'responsive');
   drupal_add_js($path . '/js/jquery.snap.js', array('type' =&gt; 'file', 'scope' 
   =&gt; 'header'));
   drupal_add_js($path . '/js/jquery.snap2.js', array('type' =&gt; 'file', 'scope'
   =&gt;'header'));
  }
}


Here is the original JS code

&lt;script type="text/javascript"&gt;
document.write(unescape("%3Cscript src='" 
+((document.location.protocol=="https:")?"https://snapabug.appspot.com":
"http: //www.snapengage.com") + "/snapabug.js' type='text/javascript
'%3E%3C /script%3E"));
&lt;/script&gt;
&lt;script type="text/javascript"&gt;
SnapABug.addButton("77777-7777","0","50%", true);
&lt;/script&gt;


I put the code in two separate JS files (couldn't get it to work in a single file)

jquery.snap.js

(function($) {
document.write(unescape("%3Cscript src='" 
+  ((document.location.protocol=="https:")?"https://snapabug.appspot.com":
"http: //www.snapengage.com") + "/snapabug.js' type='text/javascript
'%3E%3C /script%3E"));
})(jQuery);


jquery.snap2.js

(function($) {
SnapABug.addButton("77777-7777","0","50%", true);
})(jQuery);


When I look at the HTML source I see an error for jquery.snap2.js: "Uncaught Reference Error: SnapBug is not defined." The result is the snapabug.js is not loading. This error does not occur on the administrative side and the snapabug.js does load.
Drupal does not load jQuery if there are no dependency on it.

When drupal_add_js() is used once any where, Drupal includes jQuery automatically.

In case of user session, admin menu and overlay are dependent on jQuery so it is added automatically. So i advise you to try your drupal_add_js() code in hook_init just for try. I am not confirmed if it does not have any effect if it is called in hook_preprocess.

Please also check if you hook_node_preprocess is working at all?