Setup and manage header bidding advertising partners without writing code or confusing line items. Prebid.js is open source and free.
Switch branches/tags
Clone or download
EMXDigital and jaiminpanchal27 Updating bidrequestvalid and protocol checks. (#3297)
* Submitting EMX Digital Prebid Adapter

Submitting EMX Digital Prebid Adapter code

* fixing lint errors. updating our md

* updating to const/let variables. adding test spec.

* fixed linting on test spec js

* adding emx usersync methods

* updating valid bid request checks and protocol check.

* remove includes replaced with indexOf
Latest commit f5890e8 Nov 16, 2018
Permalink
Failed to load latest commit information.
.circleci upgrade to gulp 4 (#2930) Sep 5, 2018
.github Update stalebot labels (#2319) Mar 26, 2018
integrationExamples Add code, test, and doc for Adikteev adapter (#3229) Oct 30, 2018
modules Updating bidrequestvalid and protocol checks. (#3297) Nov 16, 2018
plugins Remove require.ensure entirely (#1816) Nov 14, 2017
src only set mediaTypes.banner.sizes from sizes if mediaTypes doesn't exi… Nov 15, 2018
test otm (#3302) Nov 16, 2018
.babelrc Update babel plugins (#2447) May 7, 2018
.editorconfig Added an editorconfig file to match jshint and jssrc files. (#1147) May 2, 2017
.eslintrc.js 1206 eslint repair camel case (#2925) Aug 3, 2018
.gitignore Ignore test html pages (#878) Dec 15, 2016
.nvmrc Modernizing build dependencies (#1355) Jul 17, 2017
CONTRIBUTING.md Update CONTRIBUTING.md (#2757) Jun 21, 2018
LICENSE Updating license (#1717) Oct 20, 2017
PREBID_VERSIONING_DEPRECATION.md add versioning and deprecation policy doc (#3103) Sep 24, 2018
PR_REVIEW.md PR review and ticket coordinater updates per PMC discussion (#3050) Sep 7, 2018
README.md update gulp 4 notes on README (#3154) Oct 3, 2018
RELEASE_SCHEDULE.md update circleci link to just Prebid.js builds (#3132) Sep 27, 2018
browsers.json Temporarily remove ios browsers from browserstack testing (#2759) Jun 21, 2018
governance.md Updating core members Aug 8, 2018
gulpHelpers.js Allow bundling from node.js or with new gulp task bundle-to-stdout (#… Sep 11, 2017
gulpfile.js add nolint command line option, similar to notest (#3234) Oct 26, 2018
karma.conf.maker.js fix tests running in headless chrome inside a docker environment (#2965) Aug 20, 2018
nightwatch.browserstack.json End2end testing (#571) Sep 1, 2016
nightwatch.conf.js E2etest concurrency (#982) Feb 17, 2017
nightwatch.json End2end testing (#571) Sep 1, 2016
package-lock.json Increment pre version Oct 16, 2018
package.json increment pre version Nov 13, 2018
webpack.conf.js Fix #3055 and maintain compatibility with Node v4.0.0 by removing .in… Sep 12, 2018

README.md

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

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.

Note: In the 1.24.0 release of Prebid.js we have transitioned to using gulp 4.0 from using gulp 3.9.1. To compily with gulp's recommended setup for 4.0, you'll need to have gulp-cli installed globally prior to running the general npm install. This shouldn't impact any other projects you may work on that use an earlier version of gulp in it's setup.

If you have a previous version of gulp installed globally, you'll need to remove it before installing gulp-cli. You can check if this is installed by running gulp -v and seeing the version that's listed in the CLI field of the output. If you have the gulp package installd globally, it's likely the same version that you'll see in the Local field. If you already have gulp-cli installed, it should be a lower major version (it's at version 2.0.1 at the time of the transition).

To remove the old package, you can use the command: npm rm gulp -g

Once setup, run the following command to globally install the gulp-cli package: npm install gulp-cli -g

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/dev/prebid.js - Full source code for dev and debug
  • ./build/dev/prebid.js.map - Source map for dev and debug
  • ./build/dist/prebid.js - Minified production code
  • ./prebid.js_<version>.zip - Distributable zip archive

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

  • Clone the repo, run npm install

  • Then run the build:

      $ gulp build --modules=openxBidAdapter,rubiconBidAdapter,sovrnBidAdapter
    

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

[
  "openxBidAdapter",
  "rubiconBidAdapter",
  "sovrnBidAdapter"
]

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.

  • Add prebid.js as a npm dependency of your project: npm install prebid.js

  • Run the prebid.js build under the node_modules/prebid.js/ folder

      $ gulp build --modules=path/to/your/list-of-modules.json
    

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

  • A change in your list of modules
  • A new release of prebid.js

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:

gulp lint

To run the unit tests:

gulp test

To generate and view the code coverage reports:

gulp test-coverage
gulp 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:

(function() {
    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:

(function() {
    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:

gulp 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:

  • http://localhost:9999/integrationExamples/gpt/pbjs_example_gpt.html

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.

  • To access the Karma debug page, go to http://localhost:9876/debug.html

  • For test results, see the console

  • To set breakpoints in source code, see the 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.