Responsive AdSense Ads Allowed Now

The Google AdSense team has officially confirmed that publishers can use JavaScript to server ads of different size based on the screen size of the visitor.

Google AdSense ads are fixed-width but there’s a little workaround that can  make your Google ads responsive. The idea is that if a visitor is reading your web page on a large desktop screen, they are served the large 728×60 or 336×280 units while if another visitor is viewing the same page on a smaller mobile screen, you can dynamically serve the 200×200 (or similar) ad unit.

Michel Wester of, an AdSense publisher from Netherlands, contacted the Google AdSense team for a confirmation and here’s the official response (in Dutch):
Responsive Google Ads,Responsive AdSense Ads Allowed Now,Adsense ads,Adsense customize
click for enlarge image

De voorbeeld website die u stuurt geeft al de juiste javascript code die u kunt gebruiken.” Google AdSense support has confirmed that Responsive Ads are allowed.

The rough Dutch to English translation is:

AdSense Ads can be adapted to different screen sizes using a simple JavaScript snippet. To take advantage of responsive design, create multiple ad formats, such as 728×90, 468×60 and 300×250. Then you implement an “if-else’ fragment so that the right ad format is displayed based on the size of the device of the user.

Here I am telling you Responsive AdSense Ads code

JavaScript – Responsive Google Ads
<script type="text/javascript">
    var width = window.innerWidth || document.documentElement.clientWidth;
    google_ad_client = "ca-publisher-id";
    if (width >= 800) {
       google_ad_slot = "ad-unit-1";
       google_ad_width = 728;
       google_ad_height = 60;
    } else if ((width < 800) && (width < 400)) {
      google_ad_slot = "ad-unit-2";
      google_ad_width = 300;
      google_ad_height = 250;
    } else {
      google_ad_slot = "ad-unit-3";
      google_ad_width = 468;
      google_ad_height = 60;
<script type="text/javascript"
       src=""> </script>

Thus you won’t violate any of the AdSense program policies for using responsive ads on your website. The JavaScript snippet isn’t modifying the AdSense code but is simply requesting a different ad unit based on the viewport width of the current visitor’s screen.