jQuery and prototype conflict: Array.shift()
Today, I had a case where I needed to use both libraries in one page.
I loaded both libraries normally, used jQuery.noConflict() to rename the $ to $j.
and renamed $ to jQuery in all the external js files that uses jQuery.
All seem to work just fine, however one of my function that is called using setTimeOut was still causing error. I know the problem is not in my code, since I already replaced all $ with jQuery.
Looking at the call stack in Chrome, I see that jQuery is calling the Array.shift() method (W3C implementation), however the prototype library override this method. and this overriding method (in prototype) causes the error. specifically this is the error raised:invalid array length.
So possible solution was to change the jQuery source code to make sure we use the W3C Array.shift(), but I don’t think it’s a good idea, since we’ll have to deal with this again when updating jQuery.
At the end I decided to remove prototype completely from the page..