smartserve.js

In this article...

We'll introduce you to smartserve, what it's used for, and how to use it synchronously and asynchronously for the best results based on your requirements.

What is smartserve?

The smartserve script is a JavaScript bundle hosted on a CDN, which contains all the code required to deliver experiences, segment users, and collect data. Each time you publish a change to a segment or experience, we republish a new version of smartserve.js that includes your changes.

TIP: You can get your smartserve script from the Settings page. See Getting Your Script.

INFO: The smartserve script must be added to each property's main domain and any subdomains.

Whether smartserve.js is added synchronously or asynchronously on a page depends on the balance between minimizing page load and minimizing flicker.

WARNING: To ensure the best possible data accuracy and experience delivery, it is important to place this script tag as early as possible on the page. For those clients that cannot add the script to <head>, and therefore opt to place the tag in <body>, it is important to understand that this will increase the time it takes for smartserve to load and will therefore impact flicker.

Minimizing page load

For the best user experience, and to minimize page load, we recommend an asynchronous setup:

<script src=’//static.goqubit.com/smartserve-1234.js’ async defer></script>

Observe the following recommendations:

  • The tag should be loaded at the head of the page
  • The tag should be loaded asynchronously
  • The tag can be loaded within a tag manager, although this is not recommended as it could potentially add flicker

In our experience, this is a suitable setup for campaigns that deliver additional messaging to a page such as personalized content, pointers, toggle sliders, and modal boxes.

With this setup, experiments designed to change the content of a landing page or homepage banners may expose the visitor to small amounts of perceived flicker.

Minimizing flicker

For clients who intend to run a full-site testing optimization program that includes landing pages, homepage takeovers, and other areas of the site where the user experience is sensitive to perceived user flicker, then we recommend the following setup:

<script src=’//static.goqubit.com/smartserve-1234.js’></script>

Observe the following recommendations:

  • The tag should be loaded at the head of the page
  • The tag should be loaded synchronously
  • The tag should be loaded outside of a tag manager

It is important to understand that this setup comes with a trade-off of increased page latency. Our testing shows that this increased latency is largely imperceptible to the end-user, but this of course depends on the connection used.

Improving performance

Clients often express concerns about the impact of smartserve on page loading and overall site performance.

Whilst Qubit has released a number of changes in the past year to minimize loading time, it is worth pointing out that the solution is typically custom to the site itself and often related to other site issues.

We do have a number of recommendations, however, that you might consider to further minimize smartserve loading time:

  • Archiving un-used experiences and segments - it is important to understand that each live and recently paused experience and each segment injects logic into smartserve and therefore contributes to its weight and the number of CPU cycles needed to execute it

    TIP: For this reason, we recommend archiving any live experiences you are no longer using and deleting any unused segments.

  • Removing jQuery - this is an option for clients that are able to ensure jQuery is loaded on a page before smartserve runs

  • Using packages - for common functionality used across experiences, using packages can have a significant positive impact on smartserve performance. Refer to our Developers section and in particular Packages for more information
Last updated: June 2020
Did you find this article useful?