Is it common practice to use jQuery in MRAID Ads (mobile only)?

435 views Asked by At

Is it common practice to use JavaScript libraries in an MRAID Ad?

I'm looking to implement a magazine-style “page-turning” user interface for an MRAID Ad on mobile only.

I can see from the documentation that jQuery is mentioned, however I'm not sure if this would be too heavy to load, worth calling a CDN (it'd probably be cached):

Using 3rd party library bindings without using their ready event method Third party libraries such as jQuery have a ready method which help facilitate a similar functionality as the mraid ready event listener. In the example of jQuery, putting the DOM click bindings inside of the ready(handler) method makes sure that the entire page has finished loading before starting execution of any other jQuery functions.

1

There are 1 answers

0
meskobalazs On

You can use jQuery, but if you want to manipulate the DOM, you have to check if the document is ready and also if mraid is ready. From the same document:

Binding your initialization to just the window.ready event ignores that the MRAID libraries may not be available yet. Likewise, listening only for mraid.ready event ignores that the HTML DOM may still be rendering. Be sure to check for both ready states - and maybe even isViewable - before triggering initialization routines.