Rich-text Reply

Optmizely using Zepto

lourensd 08-29-16

Optmizely using Zepto

Hi Optiverse,

 

We recently decided to exclude jQuery from our Optimizely script since it's already loaded and cached on our website. Aside from that we are building a version of our site (same Optimizely script without jQuery) that will have Zepto instead of jQuery.

 

My question is how well does Optimizely fall back onto Zepto or will this not work? The developers have access to wrting the experiment JS themelves if that's the only issue.

 

Thank you!

Level 1

robertchan 08-29-16
 

Re: Optmizely using Zepto

I imagine you might encounter timing issues. You could always test performance first by appending Zepto dynamically (replace the jQuery URL in the following):

 

if (typeof jQuery == 'undefined') {
	if (typeof $ == 'function') {
		// warning, global var
		thisPageUsingOtherJSLibrary = true;
	}	
	function getScript(url, success) {	
		var script     = document.createElement('script');
		    script.src=url;	
		var head = document.getElementsByTagName('head')[0],
			done = false;
		script.onload = script.onreadystatechange = function() {
			if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) {
				done = true;
				success();
				script.onload = script.onreadystatechange = null;
				head.removeChild(script);
			};
		};
		head.appendChild(script);
	};
	function runCode(){
		$('.navUtility').remove();
	}
	getScript('http://code.jquery.com/jquery-3.0.0.min.js', function() {
		if (typeof jQuery=='undefined') {
			console.log('Check code, jQuery is not loading as expected')
		} else {
			$.noConflict();
			runCode();
			if (thisPageUsingOtherJSLibrary) {
				runCode();
			} else {
				$.noConflict();
				runCode();
			}
		}
	});
} else {
	runCode();
};
Robert Chan

Experimentation Hero