You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There have been conversations about trying to make the overall PBJS built package smaller by allowing bid adapters to tag code as having a certain optional function. Publishers could then build a package that excludes certain code. For instance, if the publisher doesn't need Native support in their wrapper, it may be possible to save several KB by not including code related to support of the Native mediatype.
There were several ideas kicked around in PR #6079
Moving that conversation here.
The original proposal from @pm-harshad-mane was a pre-processor model. e.g.:
The reason this approach does reduce bundle size is that it removes live code that happens to never get run. I agree that it seems hard to maintain. To me the main issue seems to be that a lot of code looks for particular settings or request/response values that keep code alive, even if you (as the publisher) know they will never be there. I think a better approach would be to programmatically put "breakpoints" around access to those values.
For example, instead of:
switch (bid.mediaType) {
case NATIVE: doNativeStuff();
}
we could have something like:
bid.ifNative(doNativeStuff);
and define ifNative based on build settings. This would still be a major refactor, but it has the advantage that it would automatically "cascade" dead code detection to all dependencies, you wouldn't have to (for example) care about imports that only get used inside doNativeStuff like you do here.
The text was updated successfully, but these errors were encountered:
Type of issue
optimization
Description
There have been conversations about trying to make the overall PBJS built package smaller by allowing bid adapters to tag code as having a certain optional function. Publishers could then build a package that excludes certain code. For instance, if the publisher doesn't need Native support in their wrapper, it may be possible to save several KB by not including code related to support of the Native mediatype.
There were several ideas kicked around in PR #6079
Moving that conversation here.
The original proposal from @pm-harshad-mane was a pre-processor model. e.g.:
A counter-proposal (from @dgirardi):
The reason this approach does reduce bundle size is that it removes live code that happens to never get run. I agree that it seems hard to maintain. To me the main issue seems to be that a lot of code looks for particular settings or request/response values that keep code alive, even if you (as the publisher) know they will never be there. I think a better approach would be to programmatically put "breakpoints" around access to those values.
For example, instead of:
we could have something like:
and define ifNative based on build settings. This would still be a major refactor, but it has the advantage that it would automatically "cascade" dead code detection to all dependencies, you wouldn't have to (for example) care about imports that only get used inside doNativeStuff like you do here.
The text was updated successfully, but these errors were encountered: