A Web Component with Different HTML for Desktop and Mobile
Christian Schaefer has a great big write-up about dealing with web advertisements. The whole thing is interesting, first documenting all the challenges that ads present, and then presenting modern solutions to each of them.
One code snippet that caught my eye was a simple way to design a component that renders different HTML depending on the screen size.
// Mobile ad HTML code with inline script // Desktop ad HTML code with inline script
Clever. Although note that Christian ends up going a totally different route in the article.