Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prebid Core: Define "VIDEO" compile time feature flag #9543

Merged
merged 13 commits into from
Mar 30, 2023

Conversation

mbcrute
Copy link
Contributor

@mbcrute mbcrute commented Feb 14, 2023

Type of change

  • Feature
  • Does this change affect user-facing APIs or examples documented on http://prebid.org?

Description of change

Adds a "VIDEO" feature flag that can be used to remove code specific to video ads at
compile time. This PR includes Prebid core. We've also implemented this feature flag in a
handful of the bid adapters that we use and are prepared to submit additional PRs for those
modules.

With just the changes included in this PR we're able to shave ~4.1 KB off the size of our build
of Prebid.js...

$ ./node_modules/.bin/gulp build-bundle-prod --modules=modules.json > /dev/null 2>&1 && ls -l build/dist/prebid.js
-rw-r--r--  1 crutem  staff  223835 Feb 14 11:05 build/dist/prebid.js

> ./node_modules/.bin/gulp build-bundle-prod --disable=VIDEO --modules=modules.json > /dev/null 2>&1 && ls -l build/dist/prebid.js
-rw-r--r--  1 crutem  staff  219634 Feb 14 11:04 build/dist/prebid.js

Implementing the feature flag in the bid adapter modules obviously shrinks the bundle size further.

Other information

TESTING: We have been testing these changes in our fork of Prebid on our website for approximately 2 weeks. We have seen no significant changes in any of our metrics (CPM, CTR, viewability, etc).

Copy link
Collaborator

@dgirardi dgirardi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for putting this together! I think there's a few more things that can be tagged out. My strategy would be to build-bundle-verbose --disable VIDEO to get a somewhat legible compilation output and try to spot the stragglers. here's what that produces with this version, and a few of the targets that I see:

You may also want to tag out ORTB conversion utitlies for video (here's the native tagging for reference). This does not save any bytes in core, but it would for adapters that use the library which will hopefully become more and more common in time.

src/auction.js Outdated
} else if (!bidResponse.vastUrl) {
logError('videoCacheKey specified but not required vastUrl for video bid');
addBid = false;
if (FEATURES.VIDEO) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be unnecessary, if all the calls into this are skipped the function should already be removed as dead code.

src/prebid.js Outdated
@@ -995,21 +998,23 @@ $$PREBID_GLOBAL$$.getHighestCpmBids = function (adUnitCode) {
* @alias module:pbjs.markWinningBidAsUsed
*/
$$PREBID_GLOBAL$$.markWinningBidAsUsed = function (markBidRequest) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be just a stylistic difference, but I think it'd be better to not have this method rather than have it silently do nothing.

@mbcrute
Copy link
Contributor Author

mbcrute commented Feb 17, 2023

@dgirardi Thank you for the feedback and suggestions. I've pushed some additional commits to address most of them.

Regarding the video-specific logic with custom renderers, I think I agree with you that that's worth tagging as its own feature in a separate PR.

src/native.js Outdated
@@ -174,7 +174,7 @@ function isOpenRTBAssetValid(asset) {
logError(`for data asset 'type' property must be a number`);
return false;
}
} else if (asset.video) {
} else if (FEATURES.VIDEO && asset.video) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is right; if you turn off video but not native, does that mean that you don't want video within native?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point. Reverted!

@dgirardi
Copy link
Collaborator

could you "unfollow" your fork of prebid.js in circleCI? (or, if you know of a better way to convince it to use the correct account, I'm all ears).

@mbcrute
Copy link
Contributor Author

mbcrute commented Mar 1, 2023

@dgirardi Sorry, but I'm not sure how to do what you're asking.

@patmmccann
Copy link
Collaborator

fixes #9421

@ChrisHuie ChrisHuie self-requested a review March 27, 2023 16:30
@ChrisHuie ChrisHuie self-assigned this Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants