| layout | page_v2 |
|---|---|
| title | Prebid.js Modules |
| description | Module Documentation |
| sidebarType | 1 |
{:.no_toc}
The core of Prebid.js contains only the foundational code needed for header bidding. Any functionality that could be considered an add-on is part of a module. These are the major categories:
-
Any other extensible functionality - documented on this page
-
TOC {:toc}
{% assign module_pages = site.pages | where: "page_type", "module" %}
Prebid.org highly recommends that publishers utilize the following modules:
| Module | Description |
|---|---|
| {{page.display_name}} | {{page.description}} |
Modules in the Real-Time Data (RTD) category conform to a consistent set of publisher controls. The publisher can choose to run multiple RTD modules, define an overall amount of time they're willing to wait for results, and even flag some of the modules as being higher priority than others. See the realTimeData setConfig reference for more details.
{% for page in module_pages %}{% if page.recommended == true or page.vendor_specific == true or page.enable_download == false %}{% continue %}{% endif %} {% if page.module_type == "rtd" %}{% else %}{% endif %} {% endfor %}| Module | Description | RTD? | |
|---|---|---|---|
| {{page.display_name}} | {{page.description}} | yes | no |
These modules may require accounts with a service provider.
{% for page in module_pages %}{% if page.recommended == true or page.enable_download == false %}{% continue %}{% endif %}{% if page.vendor_specific == true %} {% if page.module_type == "rtd" %}{% else %}{% endif %} {% endif %}{% endfor %}| Module | Description | RTD? | |
|---|---|---|---|
| {{page.display_name}} | {{page.description}} | yes | no |
UserID modules conform to a consistent set of publisher controls. The publisher can choose to run multiple user id modules, define an overall amount of time they're willing to wait for results. See the userSync setConfig reference and the User ID Module for more details.
{% assign userid_module_pages = site.pages | where: "layout", "userid" %}
{% for page in userid_module_pages %} {% endfor %}| Module | Description | EID Source |
|---|---|---|
| {{page.title}} | {{page.description}} | {{page.eidsource}} |
There are situations where a publisher uses different modules depending on various factors, such as specific pages or locations. This creates the inconvenience of having to load a Prebid build that is larger than what a particular page actually needs. While it’s possible to work around this by creating separate Prebid builds for different pages, that approach doesn’t scale well. Since a Prebid build is composed of concatenated chunks, it’s possible to load modules separately, allowing you to have a main Prebid file that contains only the modules shared across all pages.
This is the example of loading modules separately for the self-hosted (e.g. CDN) Prebid build. Instructions for importing modules when using the npm package can be found in the Readme file
- Perform full Prebid build
gulp build - Generate the main
prebid.jsfile containing only the modules required across all pages:gulp bundle --modules=<...> - Host
build/distfolder content on your server or CDN - Check the dependencies of the modules you plan to load dynamically on the current page Dependency tree
- Load the required modules, their dependencies using script tags:
<html>
<head>
<title>Page 1</title>>
<script src="https://<your-cdn>/prebid/ortbConverter.js"></script> <!-- Depedency of openxBidAdapter !-->
<script src="https://<your-cdn>/prebid/openxBidAdapter.js"></script> <!-- Bid adapter module !-->
<script src="https://<your-cdn>/prebid/id5IdSystem.js"></script> <!-- Another module (doesn't require any additional dependencies) !-->
<script src="https://<your-cdn>/prebid/prebid.js"></script> <!-- Load prebid.js last !-->
</head>When working with the storageControl module you will need to explicitly import disclosure metadata. To do this, pair each module import with its corresponding metadata file <module>.metadata.js
<html>
<head>
<title>Page 1</title>>
<script src="https://<your-cdn>/prebid/ortbConverter.js"></script> <!-- Depedency of openxBidAdapter !-->
<script src="https://<your-cdn>/prebid/openxBidAdapter.js"></script> <!-- Bid adapter module !-->
<script src="https://<your-cdn>/prebid/openxBidAdapter.metadata.js"></script> <!-- Bid adapter module's metadata !-->
<script src="https://<your-cdn>/prebid/id5IdSystem.js"></script> <!-- Another module (doesn't require any additional dependencies) !-->
<script src="https://<your-cdn>/prebid/id5IdSystem.metadata.js"></script> <!-- Another module's metadata !-->
<script src="https://<your-cdn>/prebid/prebid.js"></script> <!-- Load prebid.js last !-->
</head>