Do I need to provide mraid.js script within the ad markup?

11.9k views Asked by At

I see many examples of MRAID ads begins with

<script src="mraid.js"></script>

Is this script is always available on every MRAID compatible device or I need to set an SRC attribute to the real mraid.js located somewhere on internet?

2

There are 2 answers

1
Zahoor On

It all depends on the SDK which is providing Ad containers for your native APPS. In case the native SDK providing the ad containers support Mraid, then yes it shall be provided by MRAID complaint SDK's. E.g I use some third party ad related SDK's for each of the platforms (IOS, Android and Windows) and all of them are Mraid complaint which means SDK will contain mraid.js.

Further whenever Ad designers specify mraid.js in their creatives, it allows the ad containers to inject the related MRAID libraries.

IAB standard specifies: "While MRAID ads need to identify themselves as such via the mraid.js script in a timely fashion so that the container can inject the MRAID libraries, ad designers should avoid using the string “mraid.js” for any other purpose in an ad creative, as doing so may lead containers/SDKs to mistakenly inject multiple copies of the MRAID libraries."

0
user12121234 On

Initializing/Starting an MRAID Ad

Always include or add “mraid.js” to the creative as early as possible. MRAID permits this either by including a script tag in the HTML, or via DOM insertion. This is a requirement for a creative to be a proper MRAID ad. Some ad designers assume that the container will automatically inject the MRAID libraries (and some containers do actually do this) but the script tag must always be included to ensure proper ad behavior in all MRAID implementations.

  1. HTML technique

    <html> <head> <script src="mraid.js"></script>

  2. DOM insertion technique

    <script type="text/javascript"> var head = document.getElementsByTagName('head').item(0), js = document.createElement('script'), s = 'mraid.js'; js.setAttribute('type', 'text/javascript'); js.setAttribute('src', s); head.appendChild(js); </script>

For more information see page 5 of the MRAID Best Practices