Dev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunitySubmit a ticketLog In
GitHubNuGetDev CommunitySubmit a ticket

Custom code and utility functions

Describes how to write JavaScript and CSS that is executed for some or all variations of an experiment

In Optimizely Performance Edge, you can write arbitrary JavaScript and CSS that is executed for some or all variations of an experiment. Code executed for all variations is called Shared Code; per-variation code is called Variation Code. Custom code in Optimizely Performance Edge works much like it does in Web.

Three things to be aware of when writing custom code for Optimizely Performance Edge experiments:

  • jQueryjQuery is not bundled in Optimizely Performance Edge projects. If you wish to use jQuery in your custom code, you must ensure it is loaded on the page outside of Optimizely Performance Edge, above the <script> element whose “src” attribute is your first-party Edge Decider URL.

  • The JavaScript API – Unlike Optimizely Web Experimentation, whose JavaScript API is exposed via window.optimizely, Optimizely Performance Edge uses window.optimizelyEdge. See the Performance Edge API Reference.

  • The availability of Optimizely-provided utility functions – In traditional Web experimentation, optimizely.get(‘utils’) provides access to utilities like waitForElement, observeSelector, poll, and waitUntil, all of which are documented in our Web Experimentation Developer's documentation. On a page running Performance Edge a reduced set of utilities is available, on window.optimizelyEdge.get('utils'). The utilities available in Optimizely Performance Edge are documented in the Performance Edge API Reference.