Load Google Adsense ads only if they are visible

Have you made your site responsive in a way, so that the sidebar does not show up in the mobile view? It was a good decision, because no one will ever scroll down to the bottom of it.

Because of this, it is totally unnecessary to load google Adsense ads there. But you know what? Whether you hide the sidebar or not, the basic Adsense code will still load your ad, slowing down your site.

Therefore I made a small snippet you can use to load Google Adsense ads only if they are visible.

With this code you not only speed up your site by not loading unnecessary ads, but  you will also get higher ActiveViews.