Ads are well supported in AMP, as you might expect since AMP is backed by Google. The main component used for including ads in your pages is amp-ad
. As with other AMP components, this has been designed with performance in mind. It's particularly important for ads to perform well since ads are often the cause of poor web page performance and slow load times. Indeed, if AMP determines that a third-party ad is affecting performance, it can stop animations or even remove them from the page.
The amp-ad
component is included with the following script:
<script async custom-element="amp-ad" src="https://cdn.ampproject.org/v0/amp-ad-0.1.js"></script>
Many ad platforms are supported; you can see a list here: ampproject.org/docs/reference/components/amp-ad. Since Adsense is one of the most widely used ad networks, let's take a look at that.