I'm trying to make a website mobile-friendly. One of the steps is to hide the right column, which has ads and non-essential data. In the CSS, I have something like this:
@media only screen {
@media handheld or (max-width: 768px) {
#column_right {display:none}
}
}
The problem is that the right column contains javascript to display ads, which will still be executed. This is bad for 2 reasons: 1. It slows down the loading of the page. 2. It is against the ad networks' TOS (because the view is still registered, even though the visitor doesn't see an ad)
How would I prevent the code in the hidden column from being executed?
Edited to add: Here is one of the javascript code blocks that I need to disable:
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- removed ad block name -->
<ins class="adsbygoogle"
style="display:inline-block;width:160px;height:600px"
data-ad-client="removed"
data-ad-slot="removed"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>