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

refresh() method on adapters #159

Closed
nickjacob opened this issue Jan 11, 2016 · 5 comments
Closed

refresh() method on adapters #159

nickjacob opened this issue Jan 11, 2016 · 5 comments
Assignees
Labels

Comments

@nickjacob
Copy link
Collaborator

Because some adapters load SDKs (AOL, OpenX) on callBids(), and different bidders have different requirements when requesting an additional pageview/auction, I was thinking it might be helpful to have an optional refresh(params) method in the adapter interface, so we can help minimize the impact during infinite scroll/slideshows & have best possible integrations on subsequent pageviews. For example the adtech adapter might look like:

refresh(params) {
  if (!window.ADTECH) {
    utils.logError('called refresh without calling _callBids first!', 'window.ADTECH is not present', ADTECH_BIDDER_NAME);
    return _callBids(params);
  }

  var bids = params.bids;
  utils._each(bids, function (bid) {
    ADTECH.refreshAd(_mapUnit(bid));
  });
}
@mkendall07
Copy link
Member

Thanks for the suggestion. It's something we'll need to add to the backlog, but will require a bit of work and testing of each adapter.

@prebid
Copy link
Collaborator

prebid commented Jan 22, 2016

@nickjacob is it possible to change the AOL/OpenX adaptor, so that they don't load the SDK on each request? It's more efficient that way as well. It may not be possible with their code today, but we can make this as a requirement, so bidders upgrade their adaptors.

@nickjacob
Copy link
Collaborator Author

we could do something like AMP does internally, like:

loadService(window, 'http://adtech.us/script.js', function () {
  window.ADTECH(); 
});

function loadService(_global, src, callback) {
  // scripts are loaded by the global passed in, so we could
  // load a script in an iframe if we wanted to
  var _scriptLoad = _global._scriptLoad || (_global._scriptLoad = {});

  if (!_scriptLoad[src]) {
    _scriptLoad[src] = [];
    // modify loadScript to take a window to load w/i
    loadScript(src, function () {
      function _call(f){ return f(_global) };
      utils._each(_scriptLoad[src], _call);
      _scriptLoad[src].push = _call;
    }, _global);
  }

  _scriptLoad[src].push(callback);
}

I think this would be good in general but idk if it would solve for all refresh() scenarios

@mkendall07
Copy link
Member

@nickjacob
I added caching to the adLoader.loadScript() function, which probably would solve this problem I think?
https://github.com/prebid/Prebid.js/pull/242/files#diff-86d571de6e2be77b9e9aa02a2b847c41R11

@protonate
Copy link
Collaborator

Closing, reopen if new info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants