WordPress Performance With Ad Networks

 In Performance

I wanted to take a moment to discuss WordPress Performance with Ad Networks. A lot of the folks I work with monetize their blogs through affiliate marketing and ad networks. While the revenue stream can be significant for sites with high page views, they usually come at a price in terms of performance. Below I’ll take you through an in depth look at one site I manage and how the presence of ad networks has caused a huge performance bottleneck.

Background

As most people know, WordPress performance is something I deal with a lot. Recently, a new client asked me to take a look at why her food blog was loading slowly. I ran her site through my normal test suite to see where the bottlenecks were. In addition to some common problems (page caching, CDN, etc) I noticed something else right away. The number of requests was abnormally high. The number of requests represents the total number of files (images, JavaScript, CSS, etc) that need to be downloaded to fully display the web page. Usually this number is 100 or less, but on this particular site, the number was close to 400!

This large number of requests in turns leads to larger page sizes (i.e. the total number of bytes a user has to download to fully render a page). Now, not all files are created equal, and downloading 400 files will certainly impact the user experience. But just how much is difficult to quantify. If the majority of those files are images or CSS, then the page will likely look incomplete while things download. If the majority of the files are JavaScript, the user impact really depends on what the JavaScript files are doing and where they are declared in the HTML structure. The browser may be unable to even start rendering the page if the JavaScript files are not deferred until the bottom of the HTML structure.

All that to say, here is a visualization of what I was seeing:

WordPress Performance with Ad Networks

Let’s examine more closely. First, I did 6 total performance runs:

  • First 2 with the Ads enabled
  • Next 3 with the Ads disabled
  • One more with Ads enabled

The top graph is total requests and page size. Notice the direct correlation between the two: as number of requests goes up, so does page size. The bottom graph shows both the YSlow and PageSpeed scores. Again, notice the direct correlation to page size and requests: as those 2 numbers go up, page scores go down. With the Ads enabled, the page size was almost 3 MB and close to 400 files. When I disabled the Ads (which was simply disabling the WordPress plugin provided by the Ad network) the page size dropped below 1 MB and the number of file was below 100. This is is more in line with where I like to see most sites when doing performance analysis.

WordPress Performance With Ad Networks

Don’t get me wrong, I’m not saying Ad networks are inherently bad. I understand they’re a large part of what drives online content and a lot of people’s livelihood. The problem is their files are hosted on servers that you have zero control over. Normally when optimizing a WordPress site we utilize techniques like page caching, CDN, etc. But we cannot apply any of these techniques to files that are not served from your WordPress server. We’re totally at the mercy of the Ad network to do their own optimization. Hopefully they’re serving files from a CDN. Hopefully they’ve minified all those files and set cache headers. Hopefully they’re following all the best practices we would want of our own sites, but we have no control over any of this.

The other issue is we don’t control the number of files. This particular ad network was injecting 300+ files on my client’s site. Again, if the files were on our own site, we could combine and minify most of the files and . We can’t force the Ad network to do the same, so we’re left having to download all the files required to serve their ads.

Finally, keep in mind we don’t know what’s in all those files and how they’re going to impact page rendering. Sure, we can open them up and edit them, but chances are they’re dynamic files that are going to change frequently. In fact you can even see during the 3 tests with the Ads enabled (above) that the number of requests varied quite a bit. And that was just over a 5-10 minute period. The key point is we’re relying on 3rd party scripts, served from 3rd party servers, that could possibly delay rendering of our own content.

Conclusion

I want to re-iterate: Ad networks are not bad. I wrote this post to highlight the potential issues of WordPress Performance with Ad networks enabled. This is a snapshot of one site using one Ad network (who I’m purposely not naming because they are a reputable company and one I deal with quite a bit). There are lots of Ad networks out there, and it’s worth being choosy. If you’ve done the work to get 30k page views a month, you want to make sure your page speeds have are not impacted by your choice of Ad network. Remember, at the end of the day, user experience is the boss. If your page takes too long to load, then trying to grow your readership and monetize your site will be a losing battle.

Recent Posts