Ensure namespace is defined

Previously this timings snippet assumed that window.r was an
defined and an object.  This ensures we don't throw errors as a
result for admin bar timings.
This commit is contained in:
David Wick
2014-12-22 17:39:05 -08:00
parent caeab56e17
commit 88e7eaab9d

View File

@@ -1667,6 +1667,7 @@ class RedditController(OAuth2ResourceController):
body_parts = list(content.rpartition("</body>"))
if body_parts[1]:
script = ('<script type="text/javascript">'
'window.r = window.r || {};'
'r.timings = %s'
'</script>') % simplejson.dumps(timings)
body_parts.insert(1, script)