Scriptaculous + JS optimizations can cause problems

Tags: 

With everyone raving about YSlow I used it to prune a new project I was doing. Well, after the results worked just great with Safari and Firefox I was thoroughly confused why it wasn't working correctly in IE. The problem was that my Script.aculo.us routines weren't working, and more specifically I was getting really weird errors when the page was loading, before any of the routines executed. Some of the errors were very vague, e.g. "'Class' is undefined", and "Effect.toggle is undefined". Well after lots of kicking around I finally tried something - I removed the defer="defer" attributes off the JS calls and it magically started working! Go figure! So, at the end of the day the lesson is that if you are using Script.aculo.us you can't use defer="defer" on your Prototype.js call, otherwise visitors using IE will be greated with a whole bunch of error messages and nothing will work.

How to reply

Care to add your own 2 cents? Let me know via Twitter or my contact page.