Make your Google Adsense blocs fit your responsive design !

This is actually quite simple. The thing is to set the ad parameters depending on the window’s size before we call the show_ads.js script.

google_ad_client = "ca-pub-XXXXXXXXXXXXXXXX";
if ( window.innerWidth>979 || window.innerWidth<768 ) {
  // If the window is larger than 979px or smaller than 768px, we set the first bloc
  google_ad_slot = "XXXXXXXXXX";
  google_ad_width = 300;
  google_ad_height = 250;
} else {
  // Otherwise, we set the second one.
  google_ad_slot = "XXXXXXXXXX";
  google_ad_width = 200;
  google_ad_height = 200;
}