Thinking in best load performance, all JS is loaded async. But in my site I am using Google Adsense. To lazy load the Google Adsense Ads, I am using the AdsenseLoader.js. But, If I load all JS async, some banners doesn't load correctly.
If I put the jQuery plugin code and the AdsenseLoader inline in the HTML, all Adsense banners loads correclty.
The code is like that in the footer:
<script defer>
/*! jQuery v1.12.4 | (c) jQuery Foundation | jquery.org/license */
!function(a,b){"object"==typeof module&&" /* ......... AND ALL JQUERY PLUGIN CODE MINIFIED HERE..... */
/* Adsense loader https://github.com/osvaldasvalutis/adsenseLoader.js */
!function(t,n,a,e){"use strict";var o=t(n) /* ......... AND ALL ADSENSELOADER PLUGIN CODE MINIFIED HERE..... */
</script>
<script async src="assets/js/main.js"></script> <!-- ALL OTHER JS FUNCIONS LOADED ASYNC -->
<!-- HERE I LOAD THE ADSENSE BANNERS -->
<script defer>
$( '.adsense' ).adsenseLoader({
'laziness': 2,
onLoad: function( $ad ){
$ad.addClass( 'adsense--loaded' );
}
});
</script>
I need to put the jQuery and AdsenseLoader inline because, if I put inside the main.js ASYNC, some adsense banners doesn't load correctly.
If I load the jQuery and AdsenseLoader as regular, like that:
<script src="assets/js/jquery.js"></script>
<script src="assets/js/adsenseloader.js"></script>
It causes a JAVASCRIPT RENDER BLOCK.
The unique way I think is to put all "critic" JS minified inline in the HTML footer, and works perfectly. But I don't know if is a good idea, because I never sawyed this in another sites.
PS.: I'm brazilian, sorry my bad english.
EDIT 1
Here is the screenshot of my footer.php
