Select platform: [HTML5](https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/preload.md.txt "View this page for the HTML5 platform docs.") [Android](https://developers.google.com/interactive-media-ads/docs/sdks/android/client-side/preload.md.txt "View this page for the Android platform docs.")

<br />

The IMA SDK supports preloading video ad assets.
You can enable this feature in your SDK integration
to provide a more seamless transition between ads and content.
This guide goes over the technical details of implementing
media preload with the IMA SDK.

## Enable preloading

To enable preloading, set [`AdsRenderingSettings.enablePreloading`](https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/reference/js/google.ima.AdsRenderingSettings#enablePreloading) to true. This must be done as a result of the `ADS_MANAGER_LOADED` event:

<br />

    function onAdsManagerLoaded(adsManagerLoadedEvent) {
      var adsRenderingSettings = new google.ima.AdsRenderingSettings();
      adsRenderingSettings.enablePreloading = true;
      ...
      var adsManager = adsManagerLoadedEvent.getAdsManager(
          videoContent, adsRenderingSettings);
    }

## Timing

The following table summarizes the changes in ad-load timing when preloading
is enabled:

| Event | With Preload | Without Preload |
|---|---|---|
| Ad VAST requested | `AdsLoader.requestAds()` | `AdsLoader.requestAds()` |
| Pre-roll loaded (single ad) | `AdsManager.init()` | `AdsManager.start()` |
| Pre-roll loaded (VMAP/Ad rules) | `AdsManager.init()` | `AdsManager.init()` |
| Mid-roll or post-roll loaded | For the 1st ad in an ad break, 8 seconds before ad start time. For consecutive ads, when the previous ad starts playing. | At ad start time. |

## Limitations

Preloading is subject to the following limitations:

- Media preloading is not available on the mobile web on iOS devices or when using the HTML5 IMA SDK on connected smart TVs.
- VPAID is preloaded, but none of the ad's dependencies---including media played by that ad---are loaded until the ad is executed.
- Autoplay must be enabled to preload VMAP ads. Ensure that `settings.isAutoPlayAdBreaks()` is set to `true`, which is the default value.
- Post-rolls are preloaded following the last mid-roll, or 8 seconds before the end of content if [`AdsRequest.contentDuration`](https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/reference/js/google.ima.AdsRequest#contentDuration) is used to set the duration.

> [!NOTE]
> **Note:** Setting `contentDuration` to the reserved value `-3` (with `contentDuration(-3)`) is a special value that identifies an unknown content duration and disables preloading for VAMP post-rolls.

## FAQ

Does media preloading load the full creative?
:   No, the creative is usually not fully loaded when ad playback begins.
    Preloading is intended for improving the user experience by minimizing the time
    it takes for the ad to load. It is not intended to support offline ad serving.

    The IMA SDK loads as much of the media as the browser allows, limited by the
    user's internet connection and the size of the creative.

Does media preloading need to be enabled for the ad's VAST as well as media?
:   No, the SDK always preloads the ad's VAST, regardless of this preload
    setting.