Skip to content

Snippet Deployment Models

intermediate

Web Experimentation applies changes by modifying the DOM before the page renders. If the snippet loads too slowly, visitors see the original page briefly before the variation appears β€” a visible flash called β€œflicker.” Flicker degrades user experience and can bias experiment results because visitors notice the change happening.

Snippet deployment strategy determines how fast the snippet reaches the browser, how cacheable it is, and how much control you have over updates. Choosing the right model is the difference between invisible experiments and noticeable page jank.

Optimizely hosts the snippet on its global CDN at cdn.optimizely.com. You add a <script> tag to your site’s <head>, and the snippet loads from the nearest CDN edge node.

Advantages:

  • Zero infrastructure to manage
  • Automatic updates when you publish experiment changes
  • Global edge network for low-latency delivery

Trade-offs:

  • Third-party domain means the browser must perform a DNS lookup and TLS handshake for cdn.optimizely.com
  • Some ad blockers and privacy tools block requests to cdn.optimizely.com
  • You cannot control cache headers or HTTP/2 prioritization

This is the right choice for most teams getting started. It works immediately and requires no server-side configuration.

You configure a CNAME record so the snippet loads from a subdomain you control (e.g., optly.yoursite.com) while still being served by Optimizely’s CDN infrastructure.

Advantages:

  • Same-origin or first-party subdomain avoids most ad blocker issues
  • DNS lookup can be pre-resolved if the subdomain shares the parent domain
  • No infrastructure to manage on your side

Trade-offs:

  • Requires DNS configuration and SSL certificate provisioning
  • Still a separate domain from your main site, so connection reuse is limited

Custom domains are a good middle ground β€” you get the reliability of Optimizely’s CDN without the third-party domain penalty.

You download the snippet file and serve it from your own infrastructure, alongside your other static assets.

Advantages:

  • Same-origin delivery eliminates the extra DNS lookup and TLS handshake entirely
  • Full control over cache headers, HTTP/2 push, and bundling
  • No ad blocker interference (the file lives on your domain)
  • Can be included in your existing asset pipeline

Trade-offs:

  • You must update the snippet file whenever experiment configuration changes. This can be automated with the Optimizely REST API or webhooks, but it is your responsibility.
  • If you bundle the snippet with other JavaScript, a snippet update requires a full redeploy
  • Stale snippets serve outdated experiment configurations

How you load the snippet matters as much as where you host it.

Synchronous loading (no async attribute) pauses HTML parsing until the snippet executes. This eliminates flicker because variation changes apply before the page renders. The trade-off is that a slow-loading snippet delays the entire page.

Asynchronous loading (with async) lets the page render while the snippet loads in the background. This avoids blocking but introduces flicker risk. Use async only when you have another flicker-prevention mechanism in place, such as Performance Edge.

Snippet size directly affects load time. A 200 KB snippet takes longer to download and parse than a 50 KB snippet, especially on mobile networks.

Factors that increase snippet size:

  • Number of active experiments β€” Each experiment adds configuration data
  • Complex audience conditions β€” Custom JavaScript audiences add code to the snippet
  • Variation code β€” Custom JavaScript in variations is bundled into the snippet
  • Historical experiments β€” Paused or archived experiments may still be included if not properly cleaned up

To keep the snippet lean:

  1. Archive experiments you are no longer analyzing
  2. Use URL targeting instead of complex JavaScript audience conditions where possible
  3. Move heavy variation logic to your own codebase and use the Optimizely API to trigger it
  4. Monitor snippet size in the Optimizely dashboard under project settings
FactorCDN (default)Custom domainSelf-hosted
Setup effortNoneDNS + SSL configBuild pipeline integration
Ad blocker resilienceLowHighHighest
Update latencyInstantInstantManual or webhook-driven
PerformanceGoodBetterBest (same-origin)
Tier requirementAll tiersAll tiersEnhanced+

For most teams, start with CDN hosting. Move to a custom domain if ad blockers are impacting your experiment reach. Graduate to self-hosting when you need maximum performance control and have the infrastructure to automate snippet updates.