Should both of them reference the same object?
Despite of most people recommend here, that is how Google Analytics's dynamic protocol snipped looked like for ages (before they moved from ga.js to analytics.js recently):
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
More info: https://developers.google.com/analytics/devguides/collection/gajs/
In new version they used '//' so browser can automatically add protocol:
'//www.google-analytics.com/analytics.js'
So if Google prefers document.location to window.location
when they need protocol in JS, I guess they have some reasons for that.
OVERALL: I personally believe that document.location
and window.location
are the same, but if giant with biggest stats about usage of browsers like Google using document.location, I recommend to follow them.