Prebid.js Explained: How Publishers Use Open Source Header Bidding
If you've read about header bidding, you've almost certainly seen the name Prebid. Prebid.js is the open source library many publishers use to run header bidding on their websites, and it has become a central piece of the open web ad stack. This guide explains what it is, how it works, and how to think about adopting it.
Technical details change between versions. Treat the example below as an illustration and follow the current Prebid documentation when you build.
What Prebid.js Is
Prebid.js is a free, open source JavaScript library maintained by the Prebid organization. It lets a publisher ask many demand partners for bids at the same time, collect the results, and pass the best one to the ad server. It is not an ad server, an exchange, or an ad network. It is the wrapper that coordinates the auction.
Because it's open source and not owned by a single ad tech company, many publishers see it as a neutral foundation. That neutrality is part of why it keeps coming up in industry debates about who controls the supply path, and why court ordered changes in the US Google ad tech case include interoperability with Prebid.
How It Works
- A page loads with Prebid.js and a list of ad units, which describe each ad slot and which bidders to ask.
- Prebid sends bid requests to the configured demand partners at the same time.
- Partners respond with bids within a timeout you set.
- Prebid picks the highest valid bid for each slot.
- The result is passed to the ad server, usually as targeting values, where it competes with direct campaigns and other demand.
- The winning ad is served.
Key Concepts
Ad units. Definitions of your ad slots, including sizes and formats, and the list of bidders for each.
Bidder adapters. Small modules that let Prebid talk to each demand partner. You include only the adapters you need.
Timeouts. How long Prebid waits for bids before moving on. Short timeouts protect page speed. Long ones may capture more bids.
Price granularity. The size of the price buckets Prebid uses when sending bids to the ad server. Finer buckets give more precise matching but need more setup.
Modules. Optional add ons for things like consent management, user identity, analytics, and price floors.
Prebid Server. A server side companion that runs auctions outside the visitor's browser. Publishers sometimes use it, or hybrid setups, to reduce browser load or to work around browser restrictions on third party scripts. Trade press has noted renewed interest in server side options after browser changes affected some vendors.
A Minimal Illustration
The snippet below shows the general shape of a Prebid setup. The bidder name and parameters are placeholders. Use the exact values your partner provides.
var adUnits = [{
code: 'div_gpt_ad_1',
mediaTypes: { banner: { sizes: [[300, 250], [300, 600]] } },
bids: [{ bidder: 'exampleBidder', params: { placementId: 'PLACEHOLDER' } }]
}];
var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];
pbjs.que.push(function () {
pbjs.addAdUnits(adUnits);
pbjs.requestBids({ bidsBackHandler: sendAdserverRequest, timeout: 1000 });
}); In practice you also configure price granularity, consent handling, and the connection to your ad server.
Benefits
- Real competition. Many partners bid at once instead of one after another.
- Transparency. You see who bid and at what level.
- Flexibility. Open source means you can choose partners and modules without lock in.
- A broad ecosystem. Many SSPs and exchanges support it.
Drawbacks
- Technical effort. Setup and maintenance require developers or a managed partner.
- Page speed risk. Too many bidders or poor timeouts can slow pages.
- Ongoing upkeep. Adapters, versions, and configuration need regular attention.
- Diminishing returns. More partners don't always mean more revenue.
Best Practices
- Start with a small set of partners that fit your traffic.
- Set timeouts using real data on late bids versus page speed.
- Review which bidders actually win and remove those that don't.
- Keep Prebid and adapters updated.
- Test changes on part of your traffic first, and compare total revenue.
- Keep ads.txt current as partners change.
- Avoid major changes during your busiest season.
Common Mistakes
- Adding every available bidder
- Leaving default timeouts untouched
- Ignoring consent configuration
- Not monitoring latency after changes
- Assuming Prebid alone solves unsold impressions
What Prebid Doesn't Solve
Prebid improves competition for impressions that have bidders. If no connected partner bids, or no bid clears your floor, the impression still goes unfilled. Many publishers pair Prebid on primary inventory with a dedicated real time layer for the impressions it leaves behind.
Frequently Asked Questions
Is Prebid.js free?
The software is open source and free to use. Costs come from engineering time, hosting if you use server side options, and any managed services you choose.
Do I need Prebid to use header bidding?
No, other wrappers exist, but Prebid is widely used and supported.
Does Prebid replace my ad server?
No. It feeds bids into your ad server, such as Google Ad Manager or another one.
Is Prebid right for small publishers?
It can be, but weigh the setup effort. Some start with simpler configurations or managed options.
Key Takeaways
- Prebid.js is the open source wrapper many publishers use to run header bidding.
- It coordinates simultaneous bids from partners through adapters and passes the winner to your ad server.
- Benefits include competition, transparency, and flexibility, while costs include setup effort and page speed risk.
- It doesn't fill impressions nobody bids on, so remnant inventory needs its own layer.