Google Adsense in development mode

How to prevent Google Adsense ads displaying in development mode

Client-side host file method

There are many browser plugins and software that will block the adsense for you, simply search Google for an ad-blocker, most will simply block the URL that the advert is served from preventing from miss-clicks and not affecting your page view stats. However, if you’re like me and prefer not to use bulk software or plugins for a simple taste then you can actually do this simply by editing your host file.

You can block the adsense JavaScript and the adverts being displayed using the host file by telling your operating system example.com is localhost. Both Windows & Mac operating systems have a host file, the location of these files are as follows:

Windows 95, 98, 98SE, ME: C:\WINDOWS\hosts
Windows NT3 and NT4: C:\WINNT\system32\drivers\etc\hosts
Windows 2K, XP, 2003, Vista, 7, 8, 10: C:\WINDOWS\system32\drivers\etc\hosts
Mac OS: /private/etc/hosts

In Windows you will need to edit the hosts file in administrator mode and in Mac OS you will need significant permissions to edit your Mac Hosts file. Simply add the following lines to your hosts file and your never see an adsense advert again, obviously this method will block all adsense adverts everywhere and not just your site.