Thursday, August 17, 2017
728x90 V3

Remove Adsense form specific page

Sometime You need remove adsense from specific page. Exp. about, contact etc. In WordPress you can make if structure, but this option is bad for server. Every page opened with will execute this code. This option will additionally burden your server. The idea is to execute code only on specific page.

I write simple javascript code that will remove ads. Add this code on your page when you want to remove ads.

<script>
function removeads() {
ads = document.getElementsByClassName('adsbygoogle');
for (i = 0; i <= ads.length+1; i++) { ads[0].parentNode.removeChild(ads[0]);}
};
window.onload = removeads;
</script>

 

 

About misho

Leave a Reply

Your email address will not be published. Required fields are marked *