Skip to content

Commit

Permalink
Merge pull request #36 from prebid/global-pbjs-check
Browse files Browse the repository at this point in the history
window.pbjs check before loading other modules
  • Loading branch information
mkendall07 committed Aug 31, 2015
2 parents 1044143 + 3adc1bf commit 65fda66
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/prebid.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/** @module pbjs */

// if pbjs already exists in global dodcument scope, use it, if not, create the object
window.pbjs = (window.pbjs || {});
window.pbjs.que = window.pbjs.que || [];
var pbjs = window.pbjs;
var CONSTANTS = require('./constants.json');
var utils = require('./utils.js');
var bidmanager = require('./bidmanager.js');
Expand All @@ -13,14 +16,11 @@ var objectType_object = 'object';
var objectType_string = 'string';
var objectType_number = 'number';

//if pbjs already exists in global dodcument scope, use it, if not, create the object
pbjs = typeof pbjs !== objectType_undefined ? pbjs : {};

var pb_preBidders = [],
pb_placements = [],
pb_bidderMap = {},
pb_targetingMap = {};


/* Public vars */
//default timeout for all bids
Expand All @@ -30,9 +30,6 @@ pbjs.logging = pbjs.logging || false;
//let the world know we are loaded
pbjs.libLoaded = true;

//if pbjs.anq command queue already exists, use it, if not create it
pbjs.que = pbjs.que || [];

//create adUnit array
pbjs.adUnits = pbjs.adUnits || [];

Expand Down Expand Up @@ -668,4 +665,4 @@ pbjs.removeCallback = function(cbId) {
//todo
};

processQue();
processQue();

0 comments on commit 65fda66

Please sign in to comment.