Disclaimer: This website requires Please enable JavaScript in your browser settings for the best experience.

The availability of features may depend on your plan type. Contact your Customer Success Manager if you have any questions.

Dev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideLegal TermsGitHubDev CommunityOptimizely AcademySubmit a ticketLog In
API Reference

Register a callback that fires when an element is added to the DOM.

let unobserve = window.optimizelyEdge.get("utils").observeSelector("#cta", function(ctaElement) {
  ctaElement.innerText = "Click me!";
  unobserve();
});

Parameters

ParameterTypeDescription
selector
required
stringA CSS selector indicating the element to wait for.
callback
required
functionThe function that will be executed each time an element is added to the DOM that matches the selector. The first argument is the exact node that is added.

Returns

ParameterTypeDescription
unobservefunctionA function that can be executed to stop observing.