Part 3 - Preloading the Ad

Published on 6th December 2018

Displaying an ad in an Instant Game is a two-stage process. First, the ad needs to be loaded. As long as the load succeeds, only then can you display it. So the first thing to do is preload the ad.

You do this by using the preloadAds method for interstitial ads:


and this is the method for rewarded video ads:


The methods take a Placement ID, which is the long code you were given when creating the Ad Placement in the previous step. It can accept either a single ID, or an array of them.

If you pass an array of IDs be sure not to pass any more than 3 in a single array, as the Instant Games API limits you to preloading a maximum of 3 different Ad Placements. Trying to load more than this will result in an error.

Preload Events

The ad will now either preload, or fail. You can listen for the various events it will emit:

this.facebook.on('adloaded', function (ad) {

    //  The ad has preloaded successfully.


this.facebook.on('adsnofill', function (placementID) {

    //  There is no ad inventory available for this placement ID.
    //  Either skip displaying ads in your game, or display something else.


this.facebook.on('adsfrequentload', function (placementID) {

    //  The ad is being loaded too frequently.
    //  Either skip displaying ads in your game, or display something else.


Assuming you received the adloaded event, you're now safe to display the ad at some point in your game.

How you deal with the failure events is up to you. Perhaps you just skip the ad entirely, or display something else in its place. It's very game specific and there is no wrong or right thing to do, just make sure you don't try to show the ad that failed to preload.

Although it's possible to preload and then display an ad right away, it's not recommended. Preloading an ad takes time, so it's better to have one ready to go the moment you need to display it to the user. The less waiting they have to do, the better.