$ jQuery window.jQuery
While implementing a perso test for Superbreak, I find it very tricky to get the code working.
Background:
Superbreak website uses very old version of jQuery 1.3.2 and Optimizely uses trimmed version of jQuery 1.6.1
"$(document).ready(function() {"
works but
"jQuery(document).ready(function() {"
doesn't work
Reason:
'$' uses trimmed version of Optimizely's jQuery and 'jQuery' try to use website's jQuery which is not available at this stage because website's jQuery (1.3.2) is placed in the body tag (somewhere in the middle of the page) and since DOM is not ready yet, this is not available. If website's jQuery was placed before Optimizely snippet, the later would have worked.
Once the DOM is ready, website's jQuery becomes available. That's why, any code inside the "$(document).ready(function() {"
that uses jQuery(<selector>) also works.
Trimmed version of jQuery doesn't have .ajaxComplete and .trigger events that's why some of the code wasn't working. For those methods, we need to use window.jQuery(document).ajaxComplete and window.jQuery(<selector>).trigger()
(1.3.2 still have those methods)