Alternative options for including CMP JS

There is some code that must be loaded on the page before other scripts (that would need to access the CMP) are loaded.  This code is separated out into a cmpStub.min.js file.  The cmp3p.js file also includes this stub code, and is only executed if the stub tag is not also on the page.  This enables a few options for publishers to integrate CMP into their pages. In each of these options, the synchronous script must be placed in the page header before any other script that may need to access the CMP.  Please select one of the following options.

 

Option 1: Synchronously load cmp3p.js

<script src="https://consent.cmp.oath.com/cmp3p.js"></script>

Pros: This is the simplest option.  There is no need to import both the cmp3p.js script and a stub tag.  

Cons: This file needs to be loaded synchronously.  Browsers will cache this file. However, when not cached, this will have a small impact on page load time.

 

Option 2: Synchronous stub tag, asynchronous cmp3p.js tag

<script src="https://consent.cmp.oath.com/cmpStub.min.js"></script>
<script src="https://consent.cmp.oath.com/cmp3p.js" async></script>

Pros: This option allows for the synchronous loading of the smaller stub tag, while asynchronously loading cmp3p.js.

Cons: There is additional network overhead with importing 2 script files, which may outweigh the benefit of loading a smaller file synchronously.

 

Option 3: Embed code from https://consent.cmp.oath.com/cmpStub.min.js in the page at build time or when serving the page (server side), and load cmp3p.js asynchronously

 

<script>/* code embedded by web server */ </script>
<script src="https://consent.cmp.oath.com/cmp3p.js" async></script>


Pros: No synchronous script import is required.  The stub code will be already embedded in the page header.  

Cons: Requires additional work by publishers to embed this script in their page.  If embedded at build time (as opposed to when the page is served), then there is potential for being out of date with the latest stub code.

Have more questions? Submit a request