Skip to content

Commit 0d9b571

Browse files
danezmathiasbynens
authored andcommitted
Fix loading of Browserscope visualization
Fixes jsperf#235. Closes jsperf#364.
1 parent 857eb80 commit 0d9b571

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

public/_js/test.js

+21-20
Original file line numberDiff line numberDiff line change
@@ -22693,6 +22693,27 @@
2269322693
var name = 'bs-chart-frame',
2269422694
iframe = createElement('iframe', name);
2269522695

22696+
addListener(iframe, 'load', function () {
22697+
// the element the charts are inserted into
22698+
me.container = query('#bs-chart', idoc)[0];
22699+
22700+
if (!me.container) return;
22701+
22702+
// Browserscope's UA div is inserted before an element with the id of "bs-ua-script"
22703+
loadScript('https://www.browserscope.org/ua?o=js', me.container).id = 'bs-ua-script';
22704+
22705+
// the "autoload" string is created following the guide at
22706+
// https://developers.google.com/loader/?hl=en#auto-loading
22707+
setTimeout(function() { loadScript('https://www.google.com/jsapi?autoload=' + encodeURIComponent('{' +
22708+
'modules:[{' +
22709+
'name:"visualization",' +
22710+
'version:1,' +
22711+
'packages:["corechart","table"],' +
22712+
'callback:ui.browserscope.load' +
22713+
'}]' +
22714+
'}'), idoc); }, 2000);
22715+
});
22716+
2269622717
iframe.id = name;
2269722718
iframe.frameBorder = 0;
2269822719
iframe.scrolling = 'no';
@@ -22733,26 +22754,6 @@
2273322754

2273422755
// the frame window of the charts
2273522756
me.chartWindow = iwin;
22736-
22737-
// ensure that content in iframe is processed by executing on next tick
22738-
setTimeout(function() {
22739-
// the element the charts are inserted into
22740-
me.container = query('#bs-chart', idoc)[0];
22741-
22742-
// Browserscope's UA div is inserted before an element with the id of "bs-ua-script"
22743-
loadScript('https://www.browserscope.org/ua?o=js', me.container).id = 'bs-ua-script';
22744-
22745-
// the "autoload" string is created following the guide at
22746-
// https://developers.google.com/loader/?hl=en#auto-loading
22747-
setTimeout(function() { loadScript('https://www.google.com/jsapi?autoload=' + encodeURIComponent('{' +
22748-
'modules:[{' +
22749-
'name:"visualization",' +
22750-
'version:1,' +
22751-
'packages:["corechart","table"],' +
22752-
'callback:ui.browserscope.load' +
22753-
'}]' +
22754-
'}'), idoc); }, 2000);
22755-
}, 1);
2275622757
});
2275722758

2275822759
// hide the chart while benchmarks are running

0 commit comments

Comments
 (0)