Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ The easiest way to use Scrollbench.js is through the bookmarklet.
1. Make a new bookmark (e.g. just bookmark this site).
2. Edit the bookmarklet to have the name "scrollbench" and set its URL to this:

javascript:!function(){function e(){window.ScrollBench&&new ScrollBench({loadConfig:!0}).start()}if(!window.ScrollBench&&!window.scrollbench_bookmarklet){window.scrollbench_bookmarklet=!0;var n=document.createElement('script');return n.src='https://raw.github.com/natduca/scrollbench.js/master/src/scrollbench.js',n.addEventListener('load',e,!1),document.getElementsByTagName('head')[0].appendChild(n),void 0}e()}();
javascript:! function () { function e () { window.ScrollBench && new ScrollBench ( { loadConfig: ! 0 } ).start () } function scriptLoaded () { window.scrollbench_bookmarklet = ! 0; var n = document.createElement ( 'script' ); n.innerHTML = this.responseText; n.addEventListener ( 'load', e, ! 1 ); document.getElementsByTagName ( 'head' )[ 0 ].appendChild ( n ); e (); } var scriptRequest = new XMLHttpRequest (); scriptRequest.addEventListener ( 'load', scriptLoaded ); scriptRequest.open ( 'GET', 'https://raw.githubusercontent.com/natduca/scrollbench.js/master/src/scrollbench.js' ); scriptRequest.send (); } ();

3. There is no 3, just run the bookmarklet:
* On desktop browsers just click it.
Expand Down
2 changes: 1 addition & 1 deletion report.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
function hashToReport () {
var el;
var value;
var report = decodeURIComponent(window.location.hash.substr(1)).split(',');
var report = decodeURIComponent(document.body.dataset.resultHash).split(',');

for ( var i = 0, l = report.length; i < l; i++ ) {
value = report[i].split('=');
Expand Down
38 changes: 28 additions & 10 deletions src/scrollbench.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
*/

(function (window, document) {
var CONFIG_URL = 'https://raw.github.com/natduca/scrollbench.js/master/src/config.js';
var REPORT_URL = '//natduca.github.com/scrollbench.js/report.html';
var CONFIG_URL = 'https://raw.githubusercontent.com/natduca/scrollbench.js/master/src/config.js';
var REPORT_URL = '//raw.githubusercontent.com/natduca/scrollbench.js/master/report.html';

var reliabilityReport = {};

Expand Down Expand Up @@ -362,10 +362,17 @@
return;
}

script = document.createElement('script');
script.src = typeof this.options.loadConfig == 'string' ? this.options.loadConfig : CONFIG_URL;
script.addEventListener('load', parseConfig, false);
document.getElementsByTagName('head')[0].appendChild(script);
function scriptLoaded() {
script = document.createElement('script');
script.innerHTML = this.responseText;
script.addEventListener('load', parseConfig, false);
document.getElementsByTagName('head')[0].appendChild(script);
}

var scriptRequest = new XMLHttpRequest ();
scriptRequest.addEventListener ( 'load', scriptLoaded );
scriptRequest.open ( 'GET', typeof this.options.loadConfig == 'string' ? this.options.loadConfig : CONFIG_URL );
scriptRequest.send ();
},

_waitForContent: function () {
Expand Down Expand Up @@ -586,10 +593,21 @@
window.scrollTo(0, 0);
}

frame.style.cssText = 'position:fixed;z-index:2147483640;bottom:0;left:0;width:100%;height:270px;padding:0;margin:0;border:0';
frame.src = REPORT_URL + '#' + encodeURIComponent(parms.join(','));
frame.id = 'scrollbench-report-frame';
document.documentElement.appendChild(frame);

function frameLoaded() {
frame.style.cssText = 'position:fixed;z-index:2147483640;bottom:0;left:0;width:100%;height:270px;padding:0;margin:0;border:0';
frame.id = 'scrollbench-report-frame';
document.documentElement.appendChild(frame);
document.getElementById(frame.id).contentWindow.document.open();
document.getElementById(frame.id).contentWindow.document.write(this.responseText);
document.getElementById(frame.id).contentWindow.document.close();
document.getElementById(frame.id).contentWindow.document.body.dataset.resultHash = encodeURIComponent(parms.join(','));
}

var frameRequest = new XMLHttpRequest ();
frameRequest.addEventListener ( 'load', frameLoaded );
frameRequest.open ( 'GET', REPORT_URL );
frameRequest.send ();

// Close button is on the same parent page to avoid cross-domain errors
close.style.cssText = 'position:fixed;z-index:2147483641;bottom:238px;right:0;width:88px;height:32px;padding:0;margin:0;border:0;background:transparent;cursor:pointer';
Expand Down