prebid/Prebid.js

Name: Prebid.js

Owner: Prebid

Description: Setup and manage header bidding advertising partners without writing code or confusing line items. Prebid.js is open source and free.

Created: 2015-07-19 03:26:23.0

Updated: 2018-05-25 02:36:07.0

Pushed: 2018-05-25 02:36:01.0

Homepage: http://prebid.org

Size: 6814

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Build Status Percentage of issues still open Average time to resolve an issue Code Climate Coverage Status devDependencies Status

Prebid.js

A free and open source library for publishers to quickly implement header bidding.

This README is for developers who want to contribute to Prebid.js. Additional documentation can be found at the Prebid homepage. Working examples can be found in the developer docs.

Table of Contents

Install
$ git clone https://github.com/prebid/Prebid.js.git
$ cd Prebid.js
$ npm install

Note: You need to have NodeJS 4.x or greater installed.

Build for Development

To build the project on your local machine, run:

$ gulp serve

This runs some code quality checks, starts a web server at http://localhost:9999 serving from the project root and generates the following files:

Build Optimization

The standard build output contains all the available modules from within the modules folder.

You might want to exclude some/most of them from the final bundle. To make sure the build only includes the modules you want, you can specify the modules to be included with the --modules CLI argument.

For example, when running the serve command: gulp serve --modules=openxBidAdapter,rubiconBidAdapter,sovrnBidAdapter

Building with just these adapters will result in a smaller bundle which should allow your pages to load faster.

Build standalone prebid.js

Alternatively, a .json file can be specified that contains a list of modules you would like to include.

$ gulp build --modules=modules.json

With modules.json containing the following


penxBidAdapter",
ubiconBidAdapter",
ovrnBidAdapter"

Build prebid.js using npm for bundling

In case you'd like to explicitly show that your project uses prebid.js and want a reproducible build, consider adding it as an npm dependency.

Most likely your custom prebid.js will only change when there's:

Having said that, you are probably safe to check your custom bundle into your project. You can also generate it in your build process.

Test locally

To lint the code:

 lint

To run the unit tests:

 test

To generate and view the code coverage reports:

 test-coverage
 view-coverage

For end-to-end testing, edit the example file ./integrationExamples/gpt/pbjs_example_gpt.html:

  1. Change {id} values appropriately to set up ad units and bidders
  2. Set the path to Prebid.js in your example file as shown below (see pbs.src).

For development:

ction() {
var d = document, pbs = d.createElement('script'), pro = d.location.protocol;
pbs.type = 'text/javascript';
pbs.src = ((pro === 'https:') ? 'https' : 'http') + './build/dev/prebid.js';
var target = document.getElementsByTagName('head')[0];
target.insertBefore(pbs, target.firstChild);
;

For deployment:

ction() {
var d = document, pbs = d.createElement('script'), pro = d.location.protocol;
pbs.type = 'text/javascript';
pbs.src = ((pro === 'https:') ? 'https' : 'http') + './build/dist/prebid.js';
var target = document.getElementsByTagName('head')[0];
target.insertBefore(pbs, target.firstChild);
;

Build and run the project locally with:

 serve

This runs lint and test, then starts a web server at http://localhost:9999 serving from the project root. Navigate to your example implementation to test, and if your prebid.js file is sourced from the ./build/dev directory you will have sourcemaps available in your browser's developer tools.

To run the example file, go to:

As you make code changes, the bundles will be rebuilt and the page reloaded automatically.

Contribute

Many SSPs, bidders, and publishers have contributed to this project. 60+ Bidders are supported by Prebid.js.

For guidelines, see Contributing.

Our PR review process can be found here.

Add a Bidder Adapter

To add a bidder adapter module, see the instructions in How to add a bidder adaptor.

Please do NOT load Prebid.js inside your adapter. If you do this, we will reject or remove your adapter as appropriate.

Code Quality

Code quality is defined by .eslintrc and errors are reported in the terminal.

If you are contributing code, you should configure your editor with the provided .eslintrc settings.

Unit Testing with Karma
    $ gulp test --watch --browsers=chrome

This will run tests and keep the Karma test browser open. If your prebid.js file is sourced from the ./build/dev directory you will also have sourcemaps available when using your browser's developer tools.

Detailed code coverage reporting can be generated explicitly with

    $ gulp test --coverage

The results will be in

    ./build/coverage

Note: Starting in June 2016, all pull requests to Prebid.js need to include tests with greater than 80% code coverage before they can be merged. For more information, see #421.

For instructions on writing tests for Prebid.js, see Testing Prebid.js.

Supported Browsers

Prebid.js is supported on IE10+ and modern browsers.

Governance

Review our governance model here.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.