This guide will use self closing tags (<script /> instead of
<script></script>) for simplicity. Most JSX and other modern compilers will
accept this syntax. However, if you are working in raw HTML, you
should manually close the tags.
You may also consider adding the defer attribute to the script tag to
optimize initial page load speed.
(Advanced) A/B testing with the script
If wanting to test with another monetization provider per client, you can use
the following code to conditionally load the Rev script.
index.js
Copy
const REV_RATE = 0.1; // 10% of users will see the Rev script const shouldUseRevIq = Math.random() < REV_RATE; const script = document.createElement('script'); if (shouldUseRevIq) { script.src = '//js.rev.iq/your-domain.com'; } else { // Load your other monetization provider // Set the attributes based on the other vendor's documentation } document.head.appendChild(script);