Why You Shouldn't Defer Or Lazy Load Slickstream

Given the importance of performance scores for websites, minimizing load time is very important.  So you may be using techniques or plugins that will defer certain scripts from loading immediately.  For Slickstream, it's important to understand the trade-off between user experience and potential performance gains, particularly as Slickstream's code is designed to have a negligible impact on load time.
 
The techniques for improving load time typically work in one of two ways.  In some cases, script tags are modified so that they won't load until a master script invokes them later in the loading cycle.  In other cases, most or all of the scripts on the page are combined into a single script, and that script is loaded later.  In either case, the loading is deferred so that preference is given to loading the basic content on the page first.  That makes sense, but unfortunately, it's not that simple.  This deferral can cause problems because some features on the page are delayed.  This approach can also create a logjam later in the loading cycle.
 
Slickstream supplements websites with additional engagement features such as site search, content recommendations, and favoriting.  This is done via a script which is added into the <head> of the page.  It is important to make sure this script is NOT deferred or combined into other scripts.  This is for two reasons.  
 

First, visitors depend on the Slickstream features added to the site for navigation.  If search is delayed, for example, frequent return visitors who expect to find it may have to wait for it to load before being able to use it.

Second, Slickstream takes extreme care with its embed script to minimize the impact on site performance and load time.  Only a few simple actions are loaded immediately.  These are the actions necessary to ensure immediate key functionality for search boxes and buttons as well as favorite buttons.  Slickstream then intentionally defers the remaining work to ensure only a negligible impact on loading.  For example, if someone clicks on a search button immediately after loading the page, Slickstream ensures that it will not miss that click.  However, after the click is captured, there may be a short delay while the full search functionality is loaded.  This ensures a good User Experience with minimal performance impact. 

Furthermore, it can be particularly problematic if the deferral strategy is to combine all scripts together into one larger script which loads late in the page load cycle.  Loading the large script can slow down everything on the page, so while it may help with initial page load performance scores, it can lead to a frustrating experience for visitors a few seconds after the page loads.  
 
So when using caching plugins or adding custom code to lazy load scripts, it's important to exclude the Slickstream embed script from these actions.  Here are instructions on how to do this for most caching plugins.