JSFiddle - React, Tailwind, and code Playground

by Patrick Hund

HTML

<div id="div1">
div1
</div>
<div id="div2">
div2
</div>
<script type="text/javascript" async src="https://www.googletagservices.com/tag/js/gpt.js"></script>
<script async src="//acdn.adnxs.com/prebid/not-for-prod/1/prebid.js"></script>
<script type="text/javascript">
  var adsStart = (new Date()).getTime();

  function detectWidth() {
    return window.screen.width || window.innerWidth || window.document.documentElement.clientWidth || Math.min(window.innerWidth, window.document.documentElement.clientWidth) || window.innerWidth || window.document.documentElement.clientWidth || window.document.getElementsByTagName('body')[0].clientWidth;
  }

  function detectDevice() {
    var width = detectWidth();
    if (width >= 992) return 'desktop';
    else if (width >= 768) return 'tablet';
    else return 'mobile';
  }

  var tableBreakSize = 960;
  var mobileBreakSize = 768;
  var device = "desktop";
  if (detectWidth() < tableBreakSize) device = "tablet";
  if (detectWidth() < mobileBreakSize) device = "mobile";

  var PREBID_TIMEOUT = 2000;
  var dfpNetwork = 183617012;

  var adsizes = [];
  adsizes["VN_Horizontal_A"] = [
    [728, 90],
    [970, 90],
    [970, 250]
  ];
  adsizes["VN_Postpage_Middle_A"] = [
    [300, 250],
    [336, 280]
  ];

  if (detectDevice() == 'tablet') {
    adsizes["VN_Horizontal_A"] = [
      [728, 90]
    ];
    adsizes["VN_Postpage_Middle_A"] = [
      [300, 250],
      [336, 280]
    ];
  }
  if (detectDevice() == 'mobile') {
    adsizes["VN_Horizontal_A"] = [
      [320, 50]
    ];
    adsizes["VN_Postpage_Middle_A"] = [
      [300, 250]
    ];
  }

  var adUnits = [{
    code: dfpNetwork + '/VN_Horizontal_A',
    mediaTypes: {
      banner: {
        sizes: adsizes["VN_Horizontal_A"]
      }
    },
    bids: [{
      bidder: 'appnexus',
      params: {
        placementId: 13531251
      }
    }]
  }, {
    code: dfpNetwork + '/VN_Postpage_Middle_A',
    mediaTypes: {
      banner: {
        sizes: adsizes['VN_Postpage_Middle_A']
     ...