Skip to content

24 ways to impress your friends

Vote down?

Ian

I’m trying to do a mobile first design and thought conditionally loading Google DFP ad tags depending on size would be a good idea. Can’t seem to get the JavaScript to be executed once it’s loaded into the document.

I’m completely new to DOM manipulation but I think what I need to do is causing me pain because you have to insert new HTML and JavaScript into the document because the ad call is dependent on a like-named id. See here: http://stackoverflow.com/questions/8610574/inserting-and-executing-conditional-javascript

Any advice would be greatly appreciated.