Lazy Loading

Lazy loading enables to call ad units only when they are likely to be viewed.

This feature allows to optimize the loading speed while impacting the viewability and consequently, the CPM of these ad units.

To activate this feature, you need to add the following code to n360Ad.setConfig :

n360Ad.setConfig({
    lazyLoading: {
        isActive: 1,
        fetchRatio: 2,
        mobileFetchRatio: 4,
        };
     });

Settings are as follows:

  • isActive : 1 or 0 depending on wether or not you want to activate the feature.

  • fetchRatio (optional) : Defines the distance between the current viewport and the div containing the ad slot, at which the ad call will be triggered. fetchRatio: 2 means that the ad call will be triggered when the ad container is 2 viewports away from the current viewport. This is the recommended default value, it can be changed to suit your needs.

  • mobileFetchRatio (optional) : Equivalent du fetchRatio for mobile devices.

If you want to exclude some ad units from this lazy loading strategy, you need to add this code to the relevant slots :.excludeFromLazyLoading()

Example : n360Ad.defineSlot('/your_GAM_network_ID/your_GAM_adunit',[[728,90],[970,250]],'div-2') .excludeFromLazyLoading();

Last updated