This example uses a test version of Prebid.js hosted on our CDN that is not recommended for production use. It includes all available adaptors. Production implementations should build from source or customize the build using the Download
page to make sure only the necessary bidder adaptors are included.
Line 8: Add size mapping to the ad unit
You can use the ad unit’s new
sizeMapping property to declaratively specify the ad sizes that should be shown when the device screen is greater than or equal to a given size.
For example, as shown in the first ad unit, if
minWidth is set to
1024, then Prebid.js will attempt to show a 300x250 ad (the first size in the array). If no ad that size is available, it will try to show a 300x600 ad. Otherwise, it will use the largest ad size in
Size mapping and screen widths
There are two cases to keep in mind when it comes to size mapping:
- If Prebid.js can detect the screen width, but no mapping is defined, Prebid.js doesn’t make a request for that ad unit at all
- If Prebid.js cannot detect the screen width, it uses the largest ad among all elements of the
sizes arrays from each mapping object