Talk to a sales representative

+1 844-822-8378

Write to us

What is the difference between sync code and async code of VWO?

Posted in Technical Integration on

An Asynchronous code snippet is just like the regular Visual Website Optimizer tracking code. However it has some benefits over the synchronous code.

  • Faster tracking code load times for your web pages
  • Enhanced data collection & accuracy
  • Elimination of tracking errors from dependencies when the JavaScript hasn’t fully loaded


This also means that if you are using asynchronous code then your website will not have loading issues due to the Visual Website Optimizer tracking code.

<!-- Start Visual Website Optimizer Asynchronous Code -->
<script type='text/javascript'>
var _vwo_code=(function(){
    var account_id=YOUR_ACCOUNT_ID,
    f=false,d=document;return{use_existing_jquery:function(){return use_existing_jquery;},library_tolerance:function(){return    library_tolerance;},finish:function(){if(!f){f=true;var a=d.getElementById('_vis_opt_path_hides');if(a)a.parentNode.removeChild(a);}},finished:function(){return f;},load:function(a){var b=d.createElement('script');b.src=a;b.type='text/javascript';b.innerText;b.onerror=function(){_vwo_code.finish();};d.getElementsByTagName('head')[0].appendChild(b);},init:function(){settings_timer=setTimeout('_vwo_code.finish()',settings_tolerance);this.load('//'+account_id+'&u='+encodeURIComponent(d.URL)+'&r='+Math.random());var a=d.createElement('style'),b='body{opacity:0 !important;filter:alpha(opacity=0) !important;background:none !important;}',h=d.getElementsByTagName('head')[0];a.setAttribute('id','_vis_opt_path_hides');a.setAttribute('type','text/css');if(a.styleSheet)a.styleSheet.cssText=b;else a.appendChild(d.createTextNode(b));h.appendChild(a);return settings_timer;}};}());_vwo_settings_timer=_vwo_code.init();
<!-- End Visual Website Optimizer Asynchronous Code -->


The Asynchronous script loads in parallel to the page while the page is loading. The variable settings_tolerance is the time for which the asynchronous script will wait till the settings for the page are loaded from VWO servers. If the page settings get loaded within this time interval then the code requests VWO library (va.js or vanj.js) from our CDN and waits till this file is loaded for a certain interval which is represented by the variable library_tolerance. If either of the files doesn’t get loaded on the page within their respective time limit then the VWO code on the page will show the control version(actual version) of the page to the user.

If you have jQuery version 1.4.2 or later installed on the page then you may set this variable to true. The variable use_existing_jquery tells the VWO tracking code whether it should the jQuery present on the page or it should request the jQuery version of VWO library from our CDN.


You can read more about the difference between Synchronous and Asynchronous codes on