How to defer the load of Viafoura widget(s)

We recommend loading the Viafoura script on all pages of your site to maximize the performance of all our tools and including the analytics tools. However, there may be circumstances where you may want to defer the loading of our script or load it on demand. In these cases, you can take the following action to customize when the script is loaded.



Make sure you load the Viafoura script prior to loading any Viafoura widgets.


  1. Remove the script tag that loads the vf-v2.js from your pages that you want to defer loading on.

  2. Use a function similar to the loadVfJs function below at the time that you are ready to load our tools.

Sample code

function loadVfJs() {
    const el = document.createElement('script');
    el.async = true;
    el.defer = true;
    el.setAttribute('src', '');