diff --git a/dfp.module b/dfp.module
index 55acbfa..270b333 100755
--- a/dfp.module
+++ b/dfp.module
@@ -37,6 +37,7 @@ function dfp_theme($existing, $type, $theme, $path) {
     'dfp_tag' => array(
       'variables' => array(
         'tag' => NULL,
+        'display_call' => NULL,
         'slug' => NULL,
       ),
       'template' => 'theme/dfp_tag',
@@ -675,6 +676,11 @@ function _dfp_js_global_settings() {
     'weight' => -10,
     'force header' => TRUE,
   );
+  // Adds async attribute. Depends on this patch https://www.drupal.org/files/issues/js_attributes-1664602-116.patch. Covered in this issue https://www.drupal.org/node/1664602.
+  // Also work with Advagg + Advagg_mod installed. Otherwise does nothing.
+  if (variable_get('dfp_async_rendering', 1)) {
+    $options['async'] = TRUE;
+  }
   drupal_add_js($js, $options);
 
   // Include a script tag for the Google Tag Services.
@@ -686,9 +692,10 @@ function _dfp_js_global_settings() {
 
   // Add global settings with a heavy weight so that they appear after all the
   // defineSlot() calls otherwise IE8 and Opera fail to display ads properly.
-  $js = 'googletag.cmd.push(function() {' . "\n";
+
+  // If async option is true wrap the following in cmd.push.
   if (variable_get('dfp_async_rendering', 1)) {
-    $js .= '  googletag.pubads().enableAsyncRendering();' . "\n";
+    $js = 'googletag.cmd.push(function() {' . "\n";
   }
   else {
      $js .= '  googletag.pubads().enableSyncRendering();' . "\n";
@@ -721,10 +728,13 @@ function _dfp_js_global_settings() {
     }
   }
 
-  $js .= '});' . "\n";
+  $js .= '  googletag.enableServices();' . "\n";
+  if (variable_get('dfp_async_rendering', 1)) {
+    $js .= '});' . "\n";
+  } 
+  
   $js .= variable_get('dfp_injected_js2', '') . "\n";
-  $js .= 'googletag.enableServices();';
-
+  
   $options = array(
     'type' => 'inline',
     'group' => JS_DEFAULT,
@@ -748,15 +758,22 @@ function _dfp_js_slot_definition($tag) {
 
   // Add the js needed to define this adSlot to <head>.
   $js = '';
+  // Add the js needed to define this adSlot to <head>.
+  if (variable_get('dfp_async_rendering', 1)) {
+    $js .= 'googletag.cmd.push(function() {' . "\n";
+  }
+
   // Start by defining breakpoints for this ad.
   if (!empty($tag->breakpoints)) {
     $breakpoints = $tag->breakpoints;
-    $js .= 'var mapping = googletag.sizeMapping()' . "\n";
+    $js .= '  var mapping = googletag.sizeMapping()' . "\n";
     foreach ($breakpoints as $breakpoint) {
       $js .= '  .addSize(' . dfp_format_size($breakpoint['browser_size']) . ', ' . dfp_format_size($breakpoint['ad_sizes']) . ')' . "\n";
     }
     $js .= '  .build();' . "\n";
   }
+
+  
   if (!empty($tag->settings['out_of_page'])) {
     $js .= 'googletag.slots["' . $tag->machinename . '"] = googletag.defineOutOfPageSlot("' . $tag->adunit . '", "' . $tag->placeholder_id . '")' . "\n";
   }
@@ -790,7 +807,13 @@ function _dfp_js_slot_definition($tag) {
   if (!empty($tag->breakpoints)) {
     $js .= '  .defineSizeMapping(mapping)' . "\n";
   }
-  $js = rtrim($js, "\n") . ';';
+  if (variable_get('dfp_async_rendering', 1)) {
+    $js = rtrim($js, "\n") . '});' . "\n";
+  } 
+  else{
+    $js = rtrim($js, "\n") . ';' . "\n";
+  }
+  
 
   $options = array(
     'type' => 'inline',
@@ -988,6 +1011,22 @@ function template_preprocess_dfp_tag(&$variables) {
     );
   }
 
+
+
+  // If async option is true wrap the display call in cmd.push.
+  if(variable_get('dfp_async_rendering', 1)){
+   $variables['display_call'] = 
+   "googletag.cmd.push(function() {
+      googletag.display(\"".$tag->placeholder_id."\");
+    });\n";
+  } 
+  else {
+   $variables['display_call']  = "googletag.display(\"".$tag->placeholder_id."\");\n";
+  }  
+
+
+
+
   // Define a javascript ad slot for this tag.
   _dfp_js_slot_definition($tag);
 
diff --git a/theme/dfp_tag.tpl.php b/theme/dfp_tag.tpl.php
index 0dd89d7..b2d893f 100644
--- a/theme/dfp_tag.tpl.php
+++ b/theme/dfp_tag.tpl.php
@@ -9,9 +9,9 @@
   <?php if (isset($slug)):
     print drupal_render($slug);
   endif; ?>
-  <script type="text/javascript">
-    googletag.cmd.push(function() {
-      googletag.display("<?php print $tag->placeholder_id ?>");
-    });
+  <?php if (isset($display_call)):?>
+    <script type="text/javascript">
+      <?php print ($display_call);?>
   </script>
+  <?php endif; ?>
 </div>
