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

Creating a dynamic TIMEOUT based on connection/device/browser

Open mjwhaley opened this issue 10 years ago • 6 comments

Has anyone built in any functionality to dynamic change the TIMEOUT of the auction based connection speed, device or browser?

If so, would anyone be interest in sharing some results/code?

mjwhaley avatar Mar 12 '16 09:03 mjwhaley

@mjwhaley We are currently investigating some possible ways to do this. Stay tuned...

mkendall07 avatar Mar 14 '16 01:03 mkendall07

I haven't implemented something like that but you can easily add checks with a library like https://github.com/matthewhudson/device.js

var PREBID_TIMEOUT = 700;
if (device.mobile()){
    PREBID_TIMEOUT = 2000;
}
if (device.tablet()){
    PREBID_TIMEOUT = 1500
}

ialex avatar Mar 14 '16 02:03 ialex

Also haven't implemented this yet but my current plan is to use Date.now()-window.performance.timing.navigationStart as a basis for PREBID_TIMEOUT. This value will be low on fast devices with a fast connection, it will be high for mobile devices on a slow connection. This way the timeout will correspond to the speed with which the page is loading.

For example:

var PREBID_TIMEOUT = Math.min(Math.max((Date.now()-window.performance.timing.navigationStart)*7, 300), 4000);

This would limit the timeout to 4 seconds (for really slow devices) but would be something closer to 300ms on a fast device.

BartVB avatar Mar 29 '16 08:03 BartVB

@mjwhaley does the solution @BartVB describes solve for your use case?

protonate avatar Mar 29 '16 17:03 protonate

Closing this, please reopen if new info.

protonate avatar Jun 07 '16 19:06 protonate

@BartVB have you tried out your solution on live sites? And if so, how well has it been performing?

chaqu170 avatar Aug 30 '16 22:08 chaqu170