Prebid.js icon indicating copy to clipboard operation
Prebid.js copied to clipboard

Use scheduler.postTask or analogue to assign tasks to background priority

Open patmmccann opened this issue 1 year ago • 3 comments

A variety of events in the project are known background type priority, and we could use fetch keepalive, sendBeacon, or scheduler.postTask to label them as such to each browser type. Examples include #12387 and #10062 is related.

Any sort of analytics call or onTimeout or onError event triggering network traffic seems like a candidate for background processing.

Alternatively, we could take control of the timing even more explicitly and add delays or tie the events to some milestone.

"Post auction, nonrendering tasks have been identified as low priority. We can add the background indication to all of them."

patmmccann avatar Dec 16 '24 16:12 patmmccann

committee feedback is that it is important that we could override this somwhow, that bidders or publishers could up the priority of things that were default background

patmmccann avatar Dec 18 '24 17:12 patmmccann

@patmmccann do you ming if I would suggest to evaluate scheduler.yield as a method to implement this behaviour instead of postTask?

The main advantages of scheduler.yield is that it would ensure there will be "continuation", that means that after yielding it will resume from the same order scripts as it would have done normally.

This is the ideal behaviour in my opinion to avoid other scripts to fight contention and preserve the order, Google Publisher Tag is also using scheduler.yield within the Ad Iframe insertion logic.

More info here: https://developer.mozilla.org/en-US/docs/Web/API/Scheduler/yield

gilbertococchi avatar Feb 11 '25 20:02 gilbertococchi

Post auction, nonrendering tasks have been identified as low priority. We can add the background indication to all of them.

patmmccann avatar Apr 21 '25 16:04 patmmccann