You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently we're being smart with document observers and doing the following:
Andy AB script is added to the <head>
User sets up the experiment, adding the experiment cohorts and conditions on which to change elements of the page
A document observer starts to listen to the DOM as it loads (but before rendering)
If the document observer finds an element in the DOM it thinks it should change, then it swaps out the DOM element
The DOM finishes loading and we unregister the document observers
The page is rendered
What could we do?
I wonder if we could achieve the same result by just putting the script at the bottom of the page
Andy AB script added to bottom of the <body> tag
User sets up the experiment, adding the experiment cohorts and conditions on which to change elements of the page
Andy AB looks for, and changes, any elements in the DOM that should change.
The DOM finishes loading (the script was at the bottom of the file anyway?)
The page is rendered
Why is the document observer better?
it listens to the DOM and takes action if it finds an element it thinks should change. This might be useful if another script loads and changes the DOM.
Why is putting the script at the bottom of the body tag better?
Generally good practice to place scripts at the end of body.
We could remove a fair bit of document observer code
Open questions
Could placing the script in the body tag cause flickering? The DOM loads, begins to render, then the script loads and swaps out elements.
Off the top of my head this shouldn't happen– rendering is blocked until scripts are loaded and executed.
The text was updated successfully, but these errors were encountered:
What are we currently doing?
Currently we're being smart with document observers and doing the following:
What could we do?
I wonder if we could achieve the same result by just putting the script at the bottom of the page
Why is the document observer better?
Why is putting the script at the bottom of the body tag better?
Open questions
The text was updated successfully, but these errors were encountered: