Coder’s Eye

A site about one of the three passions in my life.

Coder’s Eye header image 2

Tricky Drupal Javascript Loading Problem

May 7th, 2007 · 1 Comment

A short tale about squashing a bug.

You see, my mistrust for IE made me miss the real problem. What was happening was that in IE 7 on Vista, a site I’m building for a client was not loading any Javascript. It wasn’t even loading the base Javascript "jquery.js" and "drupal.js", so my site theme Javascript wasn’t working at all.

I dug in and began tracing code using my typical technique of embedding "drupal_set_message()" calls in the suspect areas. Sure enough, no Javascript was getting loaded, but only when I used my IE test machine.

The cause

I was not logged-in on the IE machine. So Drupal didn’t think I needed any Javascript. Nowhere in the code was "drupal_add_js(anything.js)" called since I didn’t have any modules that needed any Javascript.

In that case, Drupal doesn’t load any Javascript at all, so none was loaded. It was a feature, not a bug.

The fix

I just enabled one of the modules that I had been planning to use anyway, which uses the "drupal_add_js(anything.js)" call. Suddenly my IE testbox worked fine.

For once, it really wasn’t IE at fault. Amazing.

Technorati Tags: ,

Tags: Drupal · Tips

Bookmark this article

del.icio.us:Tricky Drupal Javascript Loading Problem digg:Tricky Drupal Javascript Loading Problem spurl:Tricky Drupal Javascript Loading Problem wists:Tricky Drupal Javascript Loading Problem simpy:Tricky Drupal Javascript Loading Problem newsvine:Tricky Drupal Javascript Loading Problem blinklist:Tricky Drupal Javascript Loading Problem furl:Tricky Drupal Javascript Loading Problem reddit:Tricky Drupal Javascript Loading Problem fark:Tricky Drupal Javascript Loading Problem blogmarks:Tricky Drupal Javascript Loading Problem Y!:Tricky Drupal Javascript Loading Problem smarking:Tricky Drupal Javascript Loading Problem magnolia:Tricky Drupal Javascript Loading Problem segnalo:Tricky Drupal Javascript Loading Problem gifttagging:Tricky Drupal Javascript Loading Problem

1 response so far ↓

  • 1 tim // Jul 20, 2008 at 1:38 pm

    So… how did you fix it?

Leave a Comment