Adobe Target · updated

Adobe Target flicker: prehiding with at.js and the Web SDK

Flicker is the original content showing for a moment before Target swaps in the test content. Both at.js and the Web SDK stop it by hiding the page, or part of it, until Target has answered or a timeout passes. If the library loads asynchronously you need a small prehiding snippet placed before it. The at.js and Web SDK snippets are different and are not interchangeable.

In plain words

A visitor should never see the old headline flash and then change. The fix is to keep the affected area invisible for a short time while Target decides. Hide too much for too long and the page feels slow, so the aim is to hide only what will change and to cap the wait.

at.js

  • With the auto-created global mbox, at.js sets the body opacity to 0 when it loads and back to 1 after Target responds or an error is detected. The browser still renders the page and loads its assets while it is hidden.
  • If opacity does not suit your site, Adobe says you can set bodyHiddenStyle to body {visibility:hidden !important} instead.
  • When at.js loads asynchronously, add Adobe's pre-hiding snippet before at.js, or before the tag manager if that also loads asynchronously. Its style ID is at-body-style and its default timeout is 3000 milliseconds.
  • In at.js 2.x, triggerView() manages flicker for single-page app views without extra code.
  • getOffer() and applyOffer() have no built-in flicker control; you must hide the element yourself before calling them.

Web SDK

How the library loadsWhat Adobe says to do
Synchronously (no async attribute)Set prehidingStyle in the configure command. No snippet is needed.
Asynchronously (recommended by Adobe for page performance)Add the Web SDK prehiding snippet before the library or tag embed code. It creates a style tag with the ID alloy-prehiding and removes it when Target answers or after the timeout.

Adobe describes three phases for synchronous deployments: prehiding, preprocessing and rendering. After rendering, or on any error, everything the SDK hid is shown again.

Hide less than the whole page

Both snippets take a CSS rule as a parameter. The default hides the whole body. Adobe's Web SDK page notes that hiding the whole page leads to worse page rendering performance as reported by tools like Lighthouse, and suggests hiding only the containers that will be personalised, for example #bar, #bazz { opacity: 0 !important }.

When you migrate

Adobe's migration tutorial is explicit: use the correct snippet for the Web SDK, since it uses a different style ID, alloy-prehiding. If the at.js snippet is left in place it may not work properly. The Web SDK snippet also skips hiding when the page is opened for authoring; Adobe's two pages check the address for different markers (mboxEdit in the migration tutorial, adobe_authoring_enabled in the Web SDK guide), so copy the snippet from the page that matches your set-up.

Web SDK prehiding snippet for asynchronous loading, as on Adobe's Web SDK 'Manage flicker' page

<script>
  !function(e,a,n,t){
  if (a) return;
  var i=e.head;if(i){
  var o=e.createElement("style");
  o.id="alloy-prehiding",o.innerText=n,i.appendChild(o),
  setTimeout(function(){o.parentNode&&o.parentNode.removeChild(o)},t)}}
  (document, document.location.href.indexOf("adobe_authoring_enabled") !== -1, "body { opacity: 0 !important }", 3000);
</script>

Web SDK loaded synchronously: the style goes in the configuration instead (placeholders, not real IDs)

alloy("configure", {
  datastreamId: "YOUR_DATASTREAM_ID",
  orgId: "YOUR_ORG_ID@AdobeOrg",
  prehidingStyle: "#bar, #bazz { opacity: 0 !important }"
});

What to check on a page that flickers

  1. Look at the script tag: does the library or tag embed code have the async attribute?
  2. If it is asynchronous, confirm a prehiding snippet sits before it in the head, and that it is the snippet for the library you use.
  3. If it is synchronous with the Web SDK, confirm prehidingStyle is set in the configure command.
  4. Narrow the CSS rule to the containers that tests change, so the rest of the page paints at once.
  5. Keep the timeout as a safety net; Adobe's default is 3000 milliseconds and reaching it should be rare.
  6. For single-page apps on at.js 2.x, use triggerView() so view changes are pre-hidden for you.

Related tools and pages on this site

Questions

Can I keep the at.js prehiding snippet after moving to the Web SDK?

No. Adobe says to use the Web SDK snippet because it uses the style ID alloy-prehiding; the at.js snippet may not work properly.

Does prehiding hurt page speed scores?

Adobe's Web SDK page says hiding the whole page leads to worse page rendering performance reported by tools like Lighthouse. Hiding only the personalised containers reduces that.

What happens if Target never answers?

The snippet removes the hiding style when its timeout passes, 3000 milliseconds by default, and the original content shows.

Do I need a snippet if the library loads synchronously?

Not with the Web SDK: Adobe says the snippet is not required and the style is set with prehidingStyle. With at.js and the auto-created global mbox, at.js hides the body itself.

Sources

Facts about Adobe's products on this page are from the linked Adobe pages, read on the date shown beside each. Explanations, steps and examples are ours unless marked as Adobe's. If Adobe's page and this one differ, Adobe's page is right.

Surge Migrate is not affiliated with Adobe and claims no Adobe partner status. Adobe product names are trademarks of Adobe.

Surge Migrate

Moving the website itself

This page answers one Adobe Target question. Surge Migrate moves a website from any CMS to any CMS. Converted automatically. Checked before you install.

  1. 1

    Scan

    Names the system behind your site, counts pages and templates, lists the blocks to build and the work no tool does, and gives an effort range with its working.

    Scan a site →
  2. 2

    Convert

    Each page becomes an Edge Delivery document, an AEM Core Component page and import files for 7 other systems. 10 pages free; 500 or 2,000 pages in one paid run.

    Convert your pages →
  3. 3

    Verify

    A download is offered only when its own format check passes. The report lists every field not found and every component kept as plain content. Compare old and new pages side by side.

    Parity check →
  4. 4

    Install

    You import with the target system's own tool, on your own environment. Each download's README gives the command. Your system changes only when you run it.

    How each import was tested →