Self Contained HTML5 Ad: No CDNs, No Web Fonts

A self contained HTML5 ad loads everything from inside its own ZIP. Here is how to find hidden external requests, replace web fonts, and prove the build works offline.

By the PlayableRun team··8 min read

Key takeaways - A self contained HTML5 ad loads every script, style, image, sound and font from inside its own ZIP, with no requests to other hosts. - The usual offenders are CDN-hosted libraries, web font stylesheets, remote images, analytics snippets and data fetched at runtime. - Replace web fonts with a system font stack, or embed a small, licensed font file with a relative path. - Prove it rather than assume it: serve the unzipped folder locally, watch the Network panel, then repeat with the network switched off. - Self-containment is only half the job. Click-through must still use the network's required mechanism, not a hardcoded URL.

What "self-contained" actually means

A self-contained ad is one where the ZIP is the whole product. Unzip it into an empty folder, open the main HTML file, and everything works. Nothing is fetched from your server, a CDN or a font provider.

This matters because ad networks do not serve your creative the way you serve a website. They review it in an automated environment, host it on their own infrastructure, and render it inside a sandboxed frame on someone else's page or in someone else's app. You control none of those conditions. Anything your ad needs from outside is a risk you cannot manage.

Three things go wrong most often:

  • Policy and validation failures. Validators and reviewers flag external calls. The creative is rejected, and the message does not always say which request caused it.
  • Unpredictable loading. A script on a CDN can be slow, blocked by a privacy setting or unreachable on a weak mobile connection. The ad then shows a blank frame, which is the worst outcome for a playable.
  • Silent changes. A remote file can change after your creative was approved. What the player sees is no longer what was reviewed.

If you have already met the validator, the Google Ads HTML5 validator errors article explains the messages. This article is about preventing the cause.

Where hidden external requests come from

Most outside dependencies are not things you added on purpose. They arrive with a template, a library or a design handoff. Search your project for these:

  • CDN script tags. A script element whose source is an absolute web address, pointing to a game engine, animation library or utility package.
  • Web font stylesheets. A link element or an @import rule that pulls CSS from a font host, which then pulls the font files.
  • Remote media. Images, video posters, audio files or sprite sheets referenced by absolute address.
  • Runtime fetches. Calls to fetch() or XMLHttpRequest that load level data, text strings or feature flags from a server.
  • Analytics and tracking snippets. Pixels and tags copied over from a landing page. In a network-hosted creative, measurement is normally the network's job.
  • Lazy-loaded engine parts. Some engines request WebAssembly files, workers or compressed textures on demand, from a path you never set explicitly.
  • Nested frames. An iframe element pointing at a hosted page.

The lazy-loaded parts are the ones people miss. The script tag is visible in your HTML, but the engine you bundled quietly requests a second file the first time it needs it. You only see that in the Network panel, which is why the verification step below matters.

Step 1: Bundle your code

Replace every CDN script with a local copy. Better, build the creative so the library is part of your own bundle. Keep references relative, such as ./js/game.js, not absolute or protocol-relative (a path starting with two slashes and a host name).

A few practical points:

  • Bundle only what the ad uses. A full engine pulled in for a two-screen interaction adds weight and more surface for hidden requests.
  • Remove source map comments from production files. A sourceMappingURL comment points at a file that is not in the ZIP and can appear as a failed request.
  • Check your CSS for @import rules and url() values that start with a web address.
  • Set the public path to relative. If your build tool has a "public path" or "base URL" option, an absolute value is a quiet way to send requests to your development server.

Step 2: Handle fonts without a font host

Web fonts are the most common reason a creative looks right on your machine and wrong elsewhere. A font stylesheet from a third-party host is one external request, and the font files behind it are another.

You have two clean options.

Option A: System font stack

Use fonts already on the device and accept that the look will differ slightly between Android and iOS. A stack such as system-ui, -apple-system, "Segoe UI", Roboto, sans-serif gives a sensible default almost everywhere. It loads instantly and cannot fail.

This suits body text, button labels and anything that does not carry your brand. The MDN reference for font-family explains generic families and fallback order.

Option B: Embed a font file in the ZIP

If the typeface is part of the game's identity, include the font file in your package and declare it with @font-face using a relative path. The MDN @font-face reference shows the syntax.

A few rules keep this safe:

  • Check the licence. Many fonts allow use from a hosted service but not redistribution inside a file you ship. Confirm that embedding is permitted.
  • Subset the font. An ad usually needs a handful of words and digits. Strip the rest so the file stays small.
  • Use a compressed web format such as WOFF2, which current mobile browsers support.
  • Always set a fallback in font-family, in case the file fails to load.
  • Wait for the font before drawing text to a canvas. A canvas does not re-render when a font arrives late. Load the font explicitly with the CSS Font Loading API before the first draw, or the first frame shows the fallback.

For display text such as a logo or a title card, the simplest route is often to export it as an image. The text then cannot change, shift or fall back to another font.

Step 3: Bring images, audio and data inside

Every image, sprite sheet, sound and data file should live in the ZIP and be referenced by a relative path. Two habits help here.

  • Keep a flat, predictable folder layout. It makes a search for stray absolute paths quick, and it makes the package easier to review. The HTML5 ZIP structure article covers layout and size considerations for Google Ads.
  • Inline data you would otherwise fetch. If the ad loads a small JSON file for level layout or copy, put it in the script bundle instead. That removes a request and a point of failure.

You can also embed small assets as data URIs. Use this sparingly. Base64 encoding makes files larger than the original binaries, and it makes assets harder to inspect and replace. It is a good fit for a tiny icon, not for a background image.

SVG files deserve a quick check. Namespace declarations that start with an http address are identifiers, not requests, so they are harmless. A reference inside an SVG to an external image or stylesheet is a real request.

Step 4: Remove tracking, keep the click path

Delete analytics snippets and third-party pixels from the creative. Measurement for a network-hosted ad normally happens through the network, and a tag you left in from a landing page is just an external call that can trip validation.

Do not hardcode your store URL either. A self-contained ad still needs a click mechanism, and the network defines which one. For Google Ads that means following its documented approach, either a clickTag variable or the Exit API, so the network decides where the click goes. The Exit API vs clickTag article explains the difference and when each applies. Whichever you use, check the network's current HTML5 requirements before you export, because the details change over time.

Step 5: Prove it

Do not rely on reading the code. Hidden requests only show up when the ad runs.

  1. Search the built files. Look in the final output, not your source, for strings that start with an http address, for protocol-relative paths, for @import, and for sourceMappingURL. Ignore SVG namespace identifiers.
  2. Serve it locally. Unzip the package into an empty folder and serve it with any simple static server. Opening files directly from disk can behave differently, because browsers restrict some features such as module loading and fetch on local files.
  3. Watch the Network panel. Reload with the cache disabled and play through the whole ad, including the end card. Every row should point at your own folder. Interact with everything, because lazy-loaded parts appear only when triggered.
  4. Go offline. Set the browser to offline mode and reload. The ad should still load, run and show its end card. If it breaks, the failed request tells you what you missed.
  5. Test on a real device. Open the local build on a phone, preferably on a slow connection. Check fonts, audio start and touch handling.

When you finally upload, a clean result in the network's own validator is the last confirmation. If it still complains, the disapproval causes and fixes article is a good next read.

Common mistakes

  • Trusting the dev server. Everything loads because your development server is running. Always test the final ZIP, not the project.
  • Cached files hiding a gap. A font or library cached from an earlier visit makes the build look fine. Disable the cache or use a fresh browser profile.
  • Forgetting the end card. Many teams test the interaction and never reach the last screen, where a font or image from a different source loads.
  • Editing after testing. A last-minute copy change reintroduces an old path. Re-run the checks on every export.

A short, honest next step

If you would rather not assemble and audit this by hand, PlayableRun builds a Google Ads-ready ZIP from a store listing, and you can look at live demos to see the kind of output it produces. You should still run the offline test above on any package before you upload it, whoever made it. You can try it with a free account.

Frequently asked questions

›What is a self contained HTML5 ad?

It is an ad whose ZIP holds everything it needs: HTML, scripts, styles, images, audio and fonts. When unzipped into an empty folder and opened, it works without requesting anything from another host.

›Can I use Google Fonts in an HTML5 ad for Google Ads?

Not as a link to a font host. That is an external request. Either use a system font stack or embed a font file in the ZIP with a relative path, after checking that the font licence allows redistribution.

›Are SVG namespace strings that start with http a problem?

No. Namespace declarations are identifiers, not requests, so they do not load anything. When you search your build for external URLs, expect to see them and ignore them.

›How do I test that my ad makes no external requests?

Serve the unzipped folder from a local static server, open the browser's Network panel and reload, then repeat with the network set to offline. Every request should point to your own folder, and the ad should still run.

›Does a self contained ad still need a click-through mechanism?

Yes. The ad must not hardcode a destination URL. Use the click mechanism the network requires, such as clickTag or the Exit API, so the network controls where the click goes.

Sources

Turn your store listing into a playable

Paste an App Store or Google Play link and get an HTML5 playable you can test in minutes. The first one is free.

Keep reading