Skip to content

Commit 65fda66

Browse files
committed
Merge pull request #36 from prebid/global-pbjs-check
window.pbjs check before loading other modules
2 parents 1044143 + 3adc1bf commit 65fda66

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/prebid.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
/** @module pbjs */
2-
2+
// if pbjs already exists in global dodcument scope, use it, if not, create the object
3+
window.pbjs = (window.pbjs || {});
4+
window.pbjs.que = window.pbjs.que || [];
5+
var pbjs = window.pbjs;
36
var CONSTANTS = require('./constants.json');
47
var utils = require('./utils.js');
58
var bidmanager = require('./bidmanager.js');
@@ -13,14 +16,11 @@ var objectType_object = 'object';
1316
var objectType_string = 'string';
1417
var objectType_number = 'number';
1518

16-
//if pbjs already exists in global dodcument scope, use it, if not, create the object
17-
pbjs = typeof pbjs !== objectType_undefined ? pbjs : {};
18-
1919
var pb_preBidders = [],
2020
pb_placements = [],
2121
pb_bidderMap = {},
2222
pb_targetingMap = {};
23-
23+
2424

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

33-
//if pbjs.anq command queue already exists, use it, if not create it
34-
pbjs.que = pbjs.que || [];
35-
3633
//create adUnit array
3734
pbjs.adUnits = pbjs.adUnits || [];
3835

@@ -668,4 +665,4 @@ pbjs.removeCallback = function(cbId) {
668665
//todo
669666
};
670667

671-
processQue();
668+
processQue();

0 commit comments

Comments
 (0)