Git Product home page Git Product logo

prebid.js's Introduction

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. For user-facing documentation, see Prebid.org.

Table of Contents

Install

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

If you experience errors after a version update, try a fresh install:

$ rm -rf ./node_modules && npm cache clean && npm install

Build for Dev

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

Note: You need to have node.js 4.x or greater installed to be able to run the gulp build commands.

Build Optimization

The standard build output contains all the available bidder adapters listed in adapters.json.

You might want to exclude some/most of them from the final bundle. To make sure the build only includes the adapters you want, you can make your own adapters file.

For example, in path/to/your/list-of-adapters.json, write:

    [
        "openx",
        "rubicon",
        "sovrn"
    ]

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

  • Duplicate adapters.json to e.g. list-of-adapters.json

  • Remove the unnecessary adapters from list-of-adapters.json

  • Then run the build:

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

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.

  • Install prebid.js as an npm dependency of your project

  • Duplicate node_modules/prebid.js/adapters.json to under your project path, e.g. path/to/your/list-of-adapters.json

  • Remove the unnecessary adapters

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

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

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

  • A change in your list of adapters
  • 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 configure Prebid.js to run locally, 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);
})();

To run the project locally, use:

$ gulp serve

This runs code quality checks, generates all the necessary files and 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

To view a test coverage report, go to:

  • http://localhost:9999/build/coverage/karma_html/report

A watch is also in place that will run continuous tests in the terminal as you edit code and tests.

Contribute

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

Our PR review process can be found here.

Add a Bidder Adapter

To add a bidder adapter, 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 .jscs and .jshint files and errors are reported in the terminal.

If you are contributing code, you should configure your editor with the provided .jscs and .jshint settings.

Unit Testing with Karma

    $ gulp test --watch

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 IE9+ and modern browsers.

Governance

Review our governance model here.

prebid.js's People

Contributors

mkendall07 avatar matthewlane avatar snapwich avatar anand-venkatraman avatar jaiminpanchal27 avatar naegelin avatar nickjacob avatar ikhemissi avatar protonate avatar nanek avatar amandelindex avatar ckbo3hrk avatar dugwood avatar braizhas avatar bretg avatar lntho avatar davidmh avatar bjorn-wo avatar ialex avatar hjeong12 avatar sneako avatar rizhang avatar baragona avatar jstocker76 avatar itayo155 avatar studnicky avatar niksok avatar adesmoules avatar marian-r avatar fabiobatsilva avatar

Stargazers

Williams Omayuku avatar Tino Ehrich avatar  avatar Andrew Bowman avatar Chris avatar Jared Freeze avatar  avatar Matt Fraser avatar

Watchers

J Patrick Lanigan avatar James Cloos avatar Swapon Ahamed avatar Kevin Jennison avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.