Rich-text Reply


davepowell 02-10-16
Accepted Solution


Hey people - *First post alert*

Q: We're using the jquery-cookie plug in and while trying to write a test I'm getting the error-

$.cookie is not a function

anyone have any clues as to what's going wrong?

Much thanks

JDahlinANF 02-10-16

Re: jquery-cookie

[ Edited ]

The timing of a web page running an experiment looks something like this:

1- Your HTML starts loading

2- Optimizely's code starts loading (typically with a version of jQuery included)

3- Your site loads its JavaScript, CSS, jQuery (and plugins), etc.


When the experiments run, they usually run while #3 is still happening, so more often than not, those functions and plugins will not be available to use when the variation's code executes.


You can force Optimizely to wait until after your version of jQuery (and it's plugins) are loaded by using


Whenever you prefix a comman with "window." it forces Optimizely to look for the window-scoped function rather than the Optimizely scoped version.  This is very useful when you have a bunch of code that works in your console but doesn't work when you run it inside of an experiment.


davepowell 02-11-16

Re: jquery-cookie

@JDahlinANF - Fantastic! It works!
Thanks a lot! Will come in super handy for future tests too!

Smiley Very Happy