Closed prebid closed 8 years ago
I'm already doing this which has reduced my prebid.min.js to 9k gzipped. In the end every byte that needs to be loaded for header bidding makes the display of creatives slower which results in a worse user experience and lower revenue.
Besides that size is not the only argument. Parsing and running prebid.js takes quite a bit of time, removing redundant code helps with keeping the pages fast (or helps with reducing the slowdown).
I've done a similar thing on my branch -- I added gulp-preprocess and changed my src/adaptermanager
to look like this:
/* @ifndef excludes.rubicon */
var RubiconAdapter = require('./adapters/rubicon.js');
this.registerBidAdapter(RubiconAdapter(), 'rubicon');
/* @endif */
/* @ifndef excludes.appnexus */
var AppNexusAdapter = require('./adapters/appnexus.js');
this.registerBidAdapter(AppNexusAdapter(), 'appnexus');
/* @endif */
/* @ifndef excludes.openx */
var OpenxAdapter = require('./adapters/openx');
this.registerBidAdapter(OpenxAdapter(), 'openx');
/* @endif */
/* @ifndef excludes.pubmatic */
var PubmaticAdapter = require('./adapters/pubmatic.js');
this.registerBidAdapter(PubmaticAdapter(), 'pubmatic');
/* @endif */
in my gulpfile I added a preprocess
task as the first dependency to build-dev
, which does something like:
preprocess({
excludes: {
index: true,
rubicon: true
}
});
Not sure if this is the best way to do this, but would make it pretty easy to add a web UI to download a custom bundle, just need to set the excludes
with query/form params from the client
Thanks for the idea @nickjacob . I think that's a good solution because it will omit the adapter sources if browserify doesn't see the require statement.
Small suggestion; I would prefer a config with 'include' instead of 'exclude'. Easier to work with without the negation.
PR #220 provides for an adapters
array in package.json to specify what adapters will be built.
As a publisher, I'd like to have prebid.js only include required bidder adaptors, so that I don't have to load up adaptors that are not relevant to me.
*Note that today prebid.js is only 15KB, so this has not become a concern yet. But please leave your comments if you think otherwise or see other problems. Thanks!