Serve different Google Ad slots based on window size

I’m wrapping up a responsive site where the client uses Google Ads to manage their ad sales. Google Ads inserts iframes for their banners, and it’s impossible to resize them when necessary. So, to handle areas of the design where I need a smaller ad size, I’m using this snippet that is based on an article I read that does it much the same way:

I don’t like this concept very much. For one, it only works on page load, not window resize. But hey, it works. And surely Google is going to figure this stuff out and help us utilize responsive ads soon.

Personally, I’d rather deliver ads locally and then I can do whatever I want, without iframes. But so much of the ad industry apparently works this way, so for now, this is all I can manage.

How are you handling advertisements for responsive design?

One thought on “Serve different Google Ad slots based on window size

Leave a Reply