University at Buffalo - The State University of New York
Skip to Content
UB Web Management

Transforming UB’s digital communications through process and tools

Content Optimization Container Causes Duplication of JavaScript

During RWD adjustments, the Content Optimization Container can cause JavaScript to run twice, with undesirable results.

Published April 29, 2015

The Issue

When the browser processes a Content Optimization Container, and that container includes additional JavaScript code, the script can run twice, with unwanted side effects. For example, content may be displayed twice, or a user-generated action may occur twice.  

Our standard components do not contain this additional code, but it may have been added to a site by a developer as custom code within HTML Package, HTML Snippet, or External Embed components.

Workaround

There is currently no fix for this problem.

The solution is to adjust how the JavaScript is used on the page. For example, if the JavaScript is called from outside of the Content Optimization Container, this duplication will not occur. 

If you have custom JavaScript coding on your site, please work with your developer to ensure it runs outside of any of these containers.