How to speed up your ad code loading on your website
Updated October 16, 2019

Having your ads code load on your site as fast as possible is vital to maximizing your ad revenue. Reading this optimization guide will give you a clearer image of what can be done to make sure you’re not leaving any ad dollars behind.

Why is it important to get ads to load as fast as possible?

Making sure you website visitors can see your ads as quickly as possible as content on your website loads is crucial for your ads to both blend seamlessly and to make sure the ad is being seen in the first place. Most CPM based ad networks only pay if the ad has actually been seen (ie. pay per active view), and not paid by impressions. In your earnings report it is just traditionally referred to impressions without active views receiving separate mention. The more active views your pageview receives, the higher your site’s revenue.

Another reason why it is so important for ads to load on your pages as quickly as possible is that ad networks, especially AdSense and Google Manager, will get the highest paying ads to display first on your page. However, in our experience, the slower a page loads, the higher the impact is on click-through-rates on ads. The lower your CTR is, the less likely it is for AdSense or Ad Manager (AdX) to reliably send you the highest paying advertisers when there are other publishers who can generate a healthier interaction between the user and top bidding ads.

General Site Speed Optimization Tips

at cover 5010 1523023673 img 800 - How to Optimize your Website for Faster Ad Loading

Optimize Your Images.

This is a no-brainer that most publishers are already doing. However, the fewest sites have switched to mostly using WEBp. Webp is a relatively new image format developed by Google specifically for serving images over the internet. Even lossless Webp optimizations from PNG or Jpg formats can oftentimes save 40%-80%.

Combine Images into CSS Sprites

Combining images into as few files as possible using CSS sprites reduces the number of round-trips and delays in downloading other resources, reduces request overhead, and can reduce the total number of bytes downloaded by a web page. This can be especially useful if your site has many small icons or smaller images that could easily be combined into a sprite.

Put all CSS in document head

This can improve how your content is being rendered.

Optimize the order in which CSS and Scripts load (Important!)

This is a big one and should not be underestimated. You want to make sure that all most essential scripts and stylesheets load asynchronously (ie. in parallel) so that content as well as ads can be loaded as fast as possible. However, if you have a render-blocking script trying to load before your ad code, then your ad networks such as AdSense or Google Ad Manager (Ad Exchange) can’t yet start the process of getting the best ads to load on your page. For example, just looking at something as simple as Font loading. Some websites use a larger number of Google fonts, especially when the website design is not been cleaned up very much. A lot of CMS like WordPress (Every WordPress Theme is different. Some are better optimized than others) will often load Google fonts by default. Most WordPress themes will then try to load those fonts before anything else on the page, so that when content start to load, the fonts have already been loaded and can display all content as intended immediately. The drawback is that oftentimes the fonts could be render-blocking. Meaning that nothing else can start to load until the current process has been completed. (More on Font optimization later.) Vital is to test the sequence of when and how your scripts and CSS loads so that you can better control where in that sequence your ad code should be. This can have a major effect on speeding up your ad code loading times. A good place to monitor your page-loading that allows you to analyze every script and image and css loading pattern is

Unnecessary Re-Directs

Make sure you have no re-directs. The more re-directs, the slower the perceived overall loading time of your website to the end-user. If the website visitor is growing tired of waiting for your site, the user will probably never even make it to the point where ads will even load, since the user has already closed the browser window or navigated elsewhere. In your analytics, make sure to always monitor your bounce rates.

Bad Requests

This refers to broken links or anything that sends a user to 404 pages or generate other error codes. Check your logs regularly and make sure all error pages and their source reason get fixed.


Http/2 is supported by most major browsers these days. However, for your website to benefit from HTTP/2 Stream Prioritization, Header Compressions and Server Push, you need to be serving your website over SSL. There was a time when only e-commerce sites would need to load over SSL. But those times are long over. Every site needs to load with an SSL certificate. The benefits are immeasurable. This guide will help you better understand HTTP/2.

Minify Your HTML

One of the fastest and easiest improvements to page load speeds is minifying your HTML. All that white space isn’t doing anyone any good except for your coder and designers who know your source code inside out already anyway. Compacting your HTML is a quick way to improve downloading, parsing and execution times of your html.

Gzip Compressions

Most publishers already do this but on the off-chance that you haven’t yet, this simple optimization method can drastically improve overall pageload speeds.

Specify Image Dimensions

Make sure you always specify exactly the width and height of each one of the images you load on your page. Failing to do so creates unnecessary work the site visitors connection and your server. Images will be rendered faster if you always give them a height and width.

Browser Caching

This is a very important optimization since it allows for dramatic page load times improvements, especially for repeat visitors. Leveraging browser caching allows for your website visitors’ browser to cache important resources. This way, when the user returns to your website, much of the static information can load nearly instantly for the user. This can lead to serious speed improvements. As a general rule of thumb you can use the following settings:

  • Truly static content (global CSS styles, logos, etc.) – access plus 1 year
  • Everything else – access plus 1 week

Make Fewer HTTP Requests

Check your loading graph on speed analysis tools like GTMetrix or Pingdom or on Webpagetest in order to check how many http requests your page makes. Many poorly optimized webpages load css and js resources on every page that should only be loaded on several pages or just on a single page. For example, some websites will load a certain font on every page, even though it is only used on a single page.

Use a CDN

Unless your website only receives visitors from a single country or very small geographic region, everybody should make use of a CDN like Cloudflare, MaxCDN, Amazon Cloud, Google Cloud, Akamai, etc. Speed is key these days, and only a CDN can effectively make sure that your website can be delivered to people that are located far away from your server or website host.

how dns works

Premium DNS

If you want the fastest deliverability of your site with the smallest chance of downtime, then using a premium DNS is probably not optional. Check out this great article by Kinsta on why a Premium DNS is a must.

Ad Code Optimization Tips

How To Speed Up Joomla Site - How to Optimize your Website for Faster Ad Loading

Minimize JS Code

Just like minimizing your HTML, you can also minimize your Javascript Code on your site. Beyond that, make sure your JS code is as lean and clean as possible. Nothing can slow down a site more than bloated JS code.

Load Ads Progessively

If you have access to Google Ad Manager you can lazy load your ads. The advantage of doing that is that the ad is only loaded when the user is about to view the portion of the page where the ad is supposed to load. This can greatly increase viewability. Your goal is to balance ad loads with ad views in such a way that your overall RPM (ie. Revenue) benefits the most. Often that means to not load as many ads as possible, but rather to serve ads as effectively as possible. Google Tag Manager Lazy Loading Guide.

Improve Site Viewability

An ad impression is only counted when at least 50% of an ads pixels have been viewed by a website visitors. In addition, the user must view the ad for no less than 1 second. If the user scrolls past the ad too quickly, no ad view will be counted. Also, the ad must be fully loaded (ie. rendered) for the ad view to count. This means loading fewer ads can often lead to higher revenue and a better user experience at the same time. Also, quality of content and attracting highly relevant users to your site will have a direct impact on your site revenues.

Responsive Design

These days most ad implementations use responsive ads. Especially AdSense and Google AdX / Ad Manager have the ability to show fully responsive ads on your website. Responsive ads work well with responsive site design since they are able to render perfectly on all types of browser, devices and screen resolutions. A better user experience directly impacts your website revenue.

Ad Count per Page

When using short form content or having short pages, limit your ad count. Oftentimes one ad unit above the fold can earn as much as four ad units below the fold. On a short form page, getting a large number of users to click on your ad below the fold, can cannibalize and significantly lower the earnings you could have earned from top bidding advertisers on your ad above the fold. Whenever you implement long form content, use lazy loading for your ads. Learn more about lazy loading your ads with Google Tag Manager here.

Ads to Users on Slow Networks

Check your analytics program often in order to determine where your website users come from and what network speeds those users have. If you have a lot of users on slow networks, try restricting your ad formats to not allow rich media formats. Oftentimes switching to responsive or native text only ads can improve ad performance for users on slow networks.

Asynchronous Ad Code

Make sure that any ad network you use serves ads exclusively asynchronously. Ads need to be loaded in parallel to your other content and scripts. AdSense and Google Ad Manager does load asynchronously by default.

Test Everything Check Everything!

The golden rule is to test every script, every css, every font, every ad placement over and over again. Most websites do not monetize effectively simply because they have a “set up once and forget’ kind of attitude.

Twitter Banner 1 1024x341 - How to Optimize your Website for Faster Ad Loading

Start maximising your site revenue!

At Pubprime we are fanatical about helping great publishers earn more with their website. Through Pubprime you can get access to ad products that the largest websites in the world to monetize their sites. We specialize in Google Ad Manager & AdSense Custom Search Ads.

We welcome you to submit your site and apply for AdSense Custom Search Ads.

Learn more about Google AdSense for Search: