Prebid.js is open source software that is offered for free as a convenience. While it is designed to help companies address legal requirements associated with header bidding, we cannot and do not warrant that your use of Prebid.js will satisfy legal requirements. You are solely responsible for ensuring that your use of Prebid.js complies with all applicable laws. We strongly encourage you to obtain legal advice when using Prebid.js to ensure your implementation complies with all laws where you operate.
Note: recommended modules are now checked by default. Please uncheck them as desired.
Note: If you receive an error during download you most likely selected a configuration that is not supported. Verify that each bidder / module is available in the selected version. Also please note that even though you can download older versions of Prebid.js, Prebid only supports the most recent major version. Within a month or so after a major release (e.g. 3.x), we won’t patch the previous major release (e.g. 2.x).
Alternatively, you can build Prebid.js from the source code. For instructions, see the Prebid.js README on GitHub.
Since Prebid.js 11.40.0, each release includes a loader, bundle.js, that assembles Prebid.js in the browser from individual modules hosted on jsDelivr. No build step is needed: list the modules you want in the script URL.
<script async src="https://cdn.jsdelivr.net/npm/prebid.js@11.40.0/dist/bundle.js?modules=rubiconBidAdapter,consentManagementTcf,tcfControl"></script>
Replace 11.40.0 with the Prebid.js version you want to use (11.40.0 or later). The loader:
bundle.js.prebid-core, the requested modules and their dependencies, plus the .metadata.js disclosure files if storageControl is one of the requested modules.<script> tag for each file, with an integrity attribute set to the file’s checksum.pbjs.que by default; see globalVarName below).The following query parameters are supported:
| Parameter | Description |
|---|---|
modules |
Modules to include, using their file names in dist/chunks/ without the .js extension (for example rubiconBidAdapter). Separate names with commas, or repeat the parameter (modules=a&modules=b). prebid-core and module dependencies are added automatically. |
globalVarName |
Name of the Prebid.js global variable. Default is pbjs. |
distUrlBase |
Base URL to load the manifest and module files from. Default is https://cdn.jsdelivr.net/npm/prebid.js@<version>/dist/chunks/. The files must be identical to the ones published with that release, as each is checked against its checksum. |
The defineGlobal build option is not supported, since the global variable is the only way to interact with Prebid.js when it is loaded this way.
If any module in the list cannot be found, no modules are loaded and the loader fails with a Cannot find modules: ... error. If a Prebid.js instance using the same global variable is already on the page, the loader aborts without loading anything, and logs a console warning if debug is enabled.
Module scripts are added with crossorigin="anonymous" and crossoriginstorage="*" attributes. crossoriginstorage comes from the Cross-Origin Storage proposal, which aims to let browsers keep a single cached copy of a file, identified by its checksum, and share it across sites. Because every site using the same Prebid.js version loads byte-identical module files, those files could be served from that shared cache. Browsers that do not support the attribute ignore it and load the files normally.
https://cdn.jsdelivr.net, or from your distUrlBase host. Because files are loaded with crossorigin="anonymous" and an integrity check, a custom distUrlBase host must also send CORS headers (Access-Control-Allow-Origin).bundle.js only works with the manifest and module files of its own release.prebid.web.js, a drop-in replacement for prebid.js that contains only the names and checksums of the selected modules and loads them from distUrlBase in the same way. In the npm package it can be found under dist/not-for-prod/. It only works when built from a tagged release: when the version ends in -pre (for example, a build of the master branch), the default distUrlBase points to latest, whose files will not match the checksums.If your project is already built with a JavaScript bundler, you can install Prebid.js from npm and bundle it with the rest of your code.
npm install prebid.js
Instead of choosing modules with --modules or the checkboxes above, you choose them by importing them, using their names from Prebid’s modules directory:
import pbjs from 'prebid.js';
import 'prebid.js/modules/rubiconBidAdapter';
import 'prebid.js/modules/userId'; // parent module of sharedIdSystem
import 'prebid.js/modules/sharedIdSystem';
pbjs.processQueue();
For complete webpack + SWC and Bun examples, see Usage (as a npm dependency) in the Prebid.js README.