Rich media developer's guide

Reduce HTML5 file size

A common complaint when switching from Flash to HTML5 is that HTML5 Creatives have large file sizes. The reason for this misconception is that Flash handles both creation and compression. In Flash, you create an authoring file (.FLA) and publish a final compressed file (.SWF).

An "HTML5" creative, on the other hand, commonly refers to ads created with HTML, CSS, and JavaScript. HTML5 Creatives provide many opportunities to compress your files. Many of the tips provided below can be implemented in under 15 minutes. The payoff is a well-compressed HTML5 Creative will perform much better than a Flash Creative.

Use Google Web Designer

Google Web Designer is a web application for HTML5 development that's integrated seamlessly with DoubleClick Studio and Asset Library. Google Web Designer's animation tools and components make it a friendly alternative for Flash users. In addition, Google Web Designer has built-in compression for images and code, Google web fonts support, SVG support, CSS animation support, and more. Get started with Google Web Designer

Check your file size

Before reducing file size, check out your current file size and review the following guidelines and terms.

Raw file size vs. compressed file size

To review your raw file size:

  • In Studio, check your Total file size in the Manage files step of the DoubleClick Studio creative workflow.
  • In Google Web Designer, click Publish > Publish locally to view Total Size (Raw) in the publish dialog.

Google Web Designer compresses creatives with the free software gzip. If you're not using Google Web Designer, you can download a free copy of gzip, compress them on your local workspace, and inspect the file size.

The publisher’s ad server may use a different means of compression, so it's a good idea to check with your publisher to resolve potential disagreements over compressed size calculations.

File size baseline

Before you build your creative, it’s essential to understand your publisher’s ad serving specifications. However, many publishers follow the IAB recommendation of 35KB (compressed) initial load for the creative and 100KB for total creative size. Initial load refers to the file size of the .HTML file in the creative, not the Enabler, Javascript, CSS, or image files.

Enabler file size

The Enabler must be included in Studio creatives, but web browsers hold a cached copy, because the same script is loaded for every Studio creative. The size of the Enabler script is 25KB (compressed) and 75KB (raw).

See the IAB and DoubleClick guidelines for additional details:

Polite load and publisher specs

Polite loading delays the loading of additional creative assets (like images and video) until the publisher's page is loaded. This is different than initial load, which refers to the size of the creative's .HTML file. Some publishers require polite loading, but it's a good idea to include it, even when it's not required. Learn how to set up polite load

Review your publisher's Rich Media HTML5 specs, which are typically different from their Rich Media Flash specs. Publishers may count file size based on the compressed gzip format, or they may prefer to count the raw file size. Individual publisher specs may differ from IAB specs depending on placement, ad type, etc. Some publishers may be more willing to compromise on build specs. Also take note of any limits for animation or video play time.

Reduce image size

Before you attempt to reduce the size of an image, first consider whether an image is even necessary. Some image elements may be replaced with CSS styles. Below are suggestions and resources for reducing the number of images in your creative and for optimizing the images you need.

Use CSS to create gradients or solid colors
CSS renders color and gradients much more efficiently than an image. For help with creating CSS gradients, use CSSmatic's Gradient Generator.
Replace GIF, JPG, and PNG with SVG (Scalable Vector Graphics)

GIF, JPG, and PNG images are pixel based (“raster”) and have larger sizes. SVGs are point-to-point based graphics (“vector”) and can greatly reduce file size.

Learn more about SVG
W3School's SVG Tutorial
How to Use SVGs
Compressing SVGs

If you're using lots of icons, consider using an icon font instead

Icon fonts are regular fonts that can be used just like standard fonts. They're often vector based, which reduces file size. If you use the same icons over and over, build your own icon font.

Icon font resources
Icomoon Icon Font Creator
NounProject css icons
FontAwesome css icons

Use a sprite sheet to optimize load time for pixel based images

A sprite sheet is a single tiled image that is loaded once. With CSS, only individual tiles of the overall image are shown. Using a sprite sheet reduces the number of HTTP requests. The fewer HTTP requests, the faster your creative loads. It's still important to find the right compression for your sprite sheet.

Sprite sheet resources
W3School's CSS Image Sprites Overview
Stitches online sprite sheet generator 

Use the best compression

If pixel based images are required, compress them as much as possible while preserving quality. You're probably familiar Photoshop’s Save For Web, but there are other online tools that offer advanced compression.

Free Image compressors

Animate with CSS

Consider using CSS3 animations for transitions and transforms instead of JavaScript. CSS transforms use the GPU (Graphics Processing Unit) instead of the CPU (Central Processing Unit) for rendering animations, which improves performance and reduces JavaScript file size.

For more complex animations (including particle animations), consider using GreenSock’s JavaScript animation libraries (GSAP). GreenSock simplifies the more cumbersome aspects of CSS animation, such as adjusting the timing of multiple animations and independently animating transform properties.

Don't use JavaScript libraries or frameworks that use JavaScript's setInterval method for animations, and do not use the setInterval method when hand coding. setInterval uses up a lot of browser resources, affects performance, and requires more code. If JavaScript animations are mandatory, then consider using the requestAnimationFrame method, which is specifically made for animations.

Learn how to optimize animation performance
Using requestAnimationFrame
CSS vs JavaScript Animations

Before uploading your CSS files to Studio, minify your CSS with a CSS Minifier.

Reduce JavaScript file size

Here are some tips for reducing your JavaScript file size:

Don’t use jQuery
jQuery adds unnecessary file size (~75k) even though the majority of the jQuery library is not used. Instead, convert from jQuery to pure JavaScript, use a minimalist library like Zepto.js, or consider GreenSock's TweenLite.
Avoid using JavaScript frameworks
Consider taking useful pieces out of a JavaScript framework for use in your main Javascript file to reduce both file size and network requests.
Target specific browsers and devices

Save time and code by deciding what browsers and devices your campaign will target. Don't add code for unsupported browsers or devices. This will also save you time during testing.

Browser support resources
Browser and device support for DoubleClick Studio
Can I Use: Up to date browser support for JS and CSS properties

Combine and compress your JavaScript
If you have multiple JavaScript files, combine them into one. Use tools that remove comments and extra whitespace from your JavaScript.

Tips for minifying
  • Keep an uncompressed copy handy for future updates.
  • DoubleClick Studio requires that JavaScript files have a .js extension, not .min.js.
  • If you minify your JavaScript files, you can't easily add tracking. Add tracking first, then minify the JavaScript file.

Optimize fonts

If you're using a font other than the standard web fonts, consider using Google Fonts, a large library of free fonts. In order to reduce file size, be sure to only request the characters you need from the font instead of the entire typeface.

However, it's also important to consider that only absolute URLs are cached by a browser. Although will be the smallest size for a specific creative, it will still be seen as a separate request from, which may already be cached in the browser history. Take advantage of caching whenever possible to make your creatives load faster.

Learn more about web fonts
Optimizing font requests with Google Web Fonts
Font subsetting for Typekit and self-hosted web fonts



Android-style image of the author of this page

Sarah is a DoubleClick Studio expert and author of this help page. Help her improve this article by leaving feedback below.

Was this article helpful?