Remove Some Element From Site for Certain Screen Width with JavaScript / jQuery

I needed to remove some div calling for ads network from mobile website display. I’ve already made it with CSS media queries, but it is better to remove the whole element, because when ads are hidden but loaded, some misunderstanding may occur with these networks. So here’s some JavaScript I’ve compiled for such task.

You will need jQuery for such code to function. Every WordPress now has it.

The only problem with the code is that when small width is changing to wider one, it will not bring ads back. But not a big problem, not many users change width when browsing. You may found a script for page reload, if needed.

Remove Empty Element with CSS

When element inside some other element with a padding removed on-the-fly you may want to remove it completely with CSS.