Google Analytics protocol check versus hardcoded string

JavaScript performance comparison

Test case created by Mathias Bynens and last updated

Preparation code

Benchmark.prototype.setup = function() {
  var location = window.location;


Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Ternary protocol check
('https:' == location.protocol ? '//ssl' : '//www') + '';
Hardcoded string

Compare results of other browsers


You can edit these tests or add even more tests to this page by appending /edit to the URL.


Abdelkrim commented :

result quite astonishing!

John-David Dalton commented :

Millions of ops/sec vs. millions of ops/sec for something that is executed 1 time means there is no real world perf concern here. Also the test with a simple string literal might be being optimized away as dead code.