Prototype and jQuery concatenation failure

Posted by Corey Hart on Stack Overflow See other posts from Stack Overflow or by Corey Hart
Published on 2010-12-21T21:23:33Z Indexed on 2010/12/21 21:54 UTC
Read the original article Hit count: 209

I found something strange when trying to concatenate prototype and jQuery. It seems as though when concatenated, the $ jquery reference doesn't get overwritten by prototype. I've built two test cases to single this out, and it's failing in Chrome8 and FF 3.6.

Test Case 1 - Without Concatenation
jQuery and Prototype are loaded separately with different script tags. jQuery is loaded first, Prototype second.

Test Case 2 - With Concatenation
jQuery and Prototype are concatenated into a single file, and loaded with a single script tag. jQuery is first in the script, and prototype is added second.

These should act identically, but the second test is throwing errors because the $ function in prototype doesn't overwrite the $ jquery reference.

Did I set these up wrong, or are browsers rendering javascript differently when it's all in the same file?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery