Skip to content

Commit 839bf02

Browse files
mathiasbynensisaacs
authored andcommitted
docs: Switch to the asynchronous Google Analytics snippet
The old snippet needlessly uses `document.write`. Let’s use the optimized version of the most recent, asynchronous GA snippet: http://mathiasbynens.be/notes/async-analytics-snippet
1 parent 1b11416 commit 839bf02

File tree

7 files changed

+65
-75
lines changed

7 files changed

+65
-75
lines changed

doc/about/index.html

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ <h1>Node's goal is to provide an easy way to build scalable
130130
<li><a href="http://twitter.com/nodejs" class="twitter">@nodejs</a></li>
131131
</ul>
132132

133-
<p>Copyright <a href="http://joyent.com">Joyent, Inc</a>, Node.js is a <a href="/trademark-policy.pdf">trademark</a> of Joyent, Inc. View <a href="https://raw.github.com/joyent/node/__VERSION__/LICENSE">license</a>.</p>
133+
<p>Copyright <a href="http://joyent.com/">Joyent, Inc</a>, Node.js is a <a href="/trademark-policy.pdf">trademark</a> of Joyent, Inc. View <a href="https://raw.github.com/joyent/node/__VERSION__/LICENSE">license</a>.</p>
134134
</div>
135135

136136

@@ -139,15 +139,14 @@ <h1>Node's goal is to provide an easy way to build scalable
139139
<script>highlight(undefined, undefined, 'pre');</script>
140140

141141
<script>
142-
var gaJsHost = (("https:" == document.location.protocol) ?
143-
"https://ssl." : "http://www.");
144-
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
145-
</script>
146-
<script>
147-
try {
148-
var pageTracker = _gat._getTracker("UA-10874194-2");
149-
pageTracker._trackPageview();
150-
} catch(err) {}
142+
window._gaq = [['_setAccount', 'UA-10874194-2'], ['_trackPageview']];
143+
(function(d, t) {
144+
var g = d.createElement(t),
145+
s = d.getElementsByTagName(t)[0];
146+
g.src = '//www.google-analytics.com/ga.js';
147+
s.parentNode.insertBefore(g, s);
148+
}(document, 'script'));
151149
</script>
150+
152151
</body>
153152
</html>

doc/blog.html

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ <h1><%- title %></h1>
103103
<%- post.content %>
104104

105105
<p class="respond">Please post feedback and comments on
106-
<a href="https://groups.google.com/group/nodejs">the Node.JS
106+
<a href="https://groups.google.com/group/nodejs">the Node.JS
107107
user mailing list</a>.</p>
108108

109109
<%
@@ -197,21 +197,20 @@ <h1><a href="<%=
197197
<li><a href="http://twitter.com/nodejs" class="twitter">@nodejs</a></li>
198198
</ul>
199199

200-
<p>Copyright <a href="http://joyent.com">Joyent, Inc</a>, Node.js is a <a href="/trademark-policy.pdf">trademark</a> of Joyent, Inc. View <a href="https://raw.github.com/joyent/node/master/LICENSE">license</a>.</p>
200+
<p>Copyright <a href="http://joyent.com/">Joyent, Inc</a>, Node.js is a <a href="/trademark-policy.pdf">trademark</a> of Joyent, Inc. View <a href="https://raw.github.com/joyent/node/master/LICENSE">license</a>.</p>
201201
</div>
202202

203203
<script src="../sh_main.js"></script>
204204
<script src="../sh_javascript.min.js"></script>
205205
<script>highlight(undefined, undefined, 'pre');</script>
206206
<script>
207-
var gaJsHost = (("https:" == document.location.protocol) ?
208-
"https://ssl." : "http://www.");
209-
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
207+
window._gaq = [['_setAccount', 'UA-10874194-2'], ['_trackPageview']];
208+
(function(d, t) {
209+
var g = d.createElement(t),
210+
s = d.getElementsByTagName(t)[0];
211+
g.src = '//www.google-analytics.com/ga.js';
212+
s.parentNode.insertBefore(g, s);
213+
}(document, 'script'));
210214
</script>
211-
<script>
212-
try {
213-
var pageTracker = _gat._getTracker("UA-10874194-2");
214-
pageTracker._trackPageview();
215-
} catch(err) {}</script>
216215
</body>
217216
</html>

doc/changelog-foot.html

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,21 @@
1515
<li><a href="http://twitter.com/nodejs" class="twitter">@nodejs</a></li>
1616
</ul>
1717

18-
<p>Copyright <a href="http://joyent.com">Joyent, Inc</a>, Node.js is a <a href="/trademark-policy.pdf">trademark</a> of Joyent, Inc. View <a href="https://raw.github.com/joyent/node/__VERSION__/LICENSE">license</a>.</p>
18+
<p>Copyright <a href="http://joyent.com/">Joyent, Inc</a>, Node.js is a <a href="/trademark-policy.pdf">trademark</a> of Joyent, Inc. View <a href="https://raw.github.com/joyent/node/__VERSION__/LICENSE">license</a>.</p>
1919
</div>
2020

2121
<script src="sh_main.js"></script>
2222
<script src="sh_javascript.min.js"></script>
2323
<script>highlight(undefined, undefined, 'pre');</script>
2424
<script>
25-
var gaJsHost = (("https:" == document.location.protocol) ?
26-
"https://ssl." : "http://www.");
27-
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
25+
window._gaq = [['_setAccount', 'UA-10874194-2'], ['_trackPageview']];
26+
(function(d, t) {
27+
var g = d.createElement(t),
28+
s = d.getElementsByTagName(t)[0];
29+
g.src = '//www.google-analytics.com/ga.js';
30+
s.parentNode.insertBefore(g, s);
31+
}(document, 'script'));
2832
</script>
29-
<script>
30-
try {
31-
var pageTracker = _gat._getTracker("UA-10874194-2");
32-
pageTracker._trackPageview();
33-
} catch(err) {}</script>
3433
</body>
3534
</html>
3635

doc/community/index.html

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@
4242
<p class="twitter"><a href="http://twitter.com/nodejs">@nodejs</a></p>
4343

4444
</div>
45-
45+
4646
<div id="column1" class="interior">
4747
<p>Node's most valuable feature is the friendly and <a href="http://blip.tv/jsconf/nodeconf-2011-marak-squires-5729610">colorful community</a> of developers. There are many places where this group congregates on the internet. This page attempts to highlight the best forums.</p>
48-
48+
4949
<div class="row clearfix">
5050
<div class="block">
5151
<h2 class="documentation">Documentation</h2>
@@ -54,7 +54,7 @@ <h2 class="documentation">Documentation</h2>
5454
<p><a href="http://www.nodemanual.org">Node Manual</a> offers stylized API docs, as well as tutorials and live code samples</p>
5555
<p><a href="http://www.nodebits.org">Node Bits</a> provides sample Node.js projects</p>
5656
<p><a href="http://docs.nodejitsu.com/">docs.nodejitsu.com</a> answers many of the common problems people come across.</p>
57-
<p><a href="http://howtonode.org/">How To Node</a> has a growing number of useful tutorials.</p>
57+
<p><a href="http://howtonode.org/">How To Node</a> has a growing number of useful tutorials.</p>
5858
<p><a href="http://stackoverflow.com/questions/tagged/node.js">Stack Overflow node.js tag</a> collects new information every day.</p>
5959
</div>
6060

@@ -77,7 +77,7 @@ <h2 class="github">GitHub</h2>
7777
</div>
7878
</div>
7979

80-
80+
8181
<div class="row clearfix">
8282
<div class="block">
8383
<h2 class="mailing">Mailing Lists</h2>
@@ -169,7 +169,7 @@ <h2 class="irc">IRC</h2>
169169
channel</a> for those who miss a day.</p>
170170
</div>
171171
</div>
172-
172+
173173
<p><a href="http://notinventedhe.re/on/2011-7-26"><img
174174
src="http://nodejs.org/images/not-invented-here.png" width="100%"></a></p>
175175
</div>
@@ -188,19 +188,17 @@ <h2 class="irc">IRC</h2>
188188
<li><a href="http://twitter.com/nodejs" class="twitter">@nodejs</a></li>
189189
</ul>
190190

191-
<p>Copyright <a href="http://joyent.com">Joyent, Inc</a>, Node.js is a <a href="/trademark-policy.pdf">trademark</a> of Joyent, Inc. View <a href="https://raw.github.com/joyent/node/__VERSION__/LICENSE">license</a>.</p>
191+
<p>Copyright <a href="http://joyent.com/">Joyent, Inc</a>, Node.js is a <a href="/trademark-policy.pdf">trademark</a> of Joyent, Inc. View <a href="https://raw.github.com/joyent/node/__VERSION__/LICENSE">license</a>.</p>
192192
</div>
193193

194194
<script>
195-
var gaJsHost = (("https:" == document.location.protocol) ?
196-
"https://ssl." : "http://www.");
197-
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
198-
</script>
199-
<script>
200-
try {
201-
var pageTracker = _gat._getTracker("UA-10874194-2");
202-
pageTracker._trackPageview();
203-
} catch(err) {}
195+
window._gaq = [['_setAccount', 'UA-10874194-2'], ['_trackPageview']];
196+
(function(d, t) {
197+
var g = d.createElement(t),
198+
s = d.getElementsByTagName(t)[0];
199+
g.src = '//www.google-analytics.com/ga.js';
200+
s.parentNode.insertBefore(g, s);
201+
}(document, 'script'));
204202
</script>
205203
</body>
206204
</html>

doc/index.html

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
<a href="#download" class="button" id="downloadbutton">Download</a>
3333
<a href="api/" class="button" id="docsbutton">Docs</a>
34-
<p class="version">__VERSION__</p>
34+
<p class="version">__VERSION__</p>
3535

3636
<a href="http://github.com/joyent/node"><img class="forkme" src="https://a248.e.akamai.net/camo.github.com/abad93f42020b733148435e2cd92ce15c542d320/687474703a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f677265656e5f3030373230302e706e67" alt="Fork me on GitHub"></a>
3737
</div>
@@ -214,7 +214,7 @@ <h2>Explore Node.js</h2>
214214
<!-- <li><a hrfe="http://twitter.com/nodejs" class="twitter">@nodejs</a></li> -->
215215
</ul>
216216

217-
<p>Copyright <a href="http://joyent.com">Joyent, Inc</a>, Node.js is a <a href="/trademark-policy.pdf">trademark</a> of Joyent, Inc. View <a href="https://raw.github.com/joyent/node/__VERSION__/LICENSE">license</a>.</p>
217+
<p>Copyright <a href="http://joyent.com/">Joyent, Inc</a>, Node.js is a <a href="/trademark-policy.pdf">trademark</a> of Joyent, Inc. View <a href="https://raw.github.com/joyent/node/__VERSION__/LICENSE">license</a>.</p>
218218
</div>
219219

220220

@@ -223,15 +223,13 @@ <h2>Explore Node.js</h2>
223223
<script>highlight(undefined, undefined, 'pre');</script>
224224

225225
<script>
226-
var gaJsHost = (("https:" == document.location.protocol) ?
227-
"https://ssl." : "http://www.");
228-
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
229-
</script>
230-
<script>
231-
try {
232-
var pageTracker = _gat._getTracker("UA-10874194-2");
233-
pageTracker._trackPageview();
234-
} catch(err) {}
226+
window._gaq = [['_setAccount', 'UA-10874194-2'], ['_trackPageview']];
227+
(function(d, t) {
228+
var g = d.createElement(t),
229+
s = d.getElementsByTagName(t)[0];
230+
g.src = '//www.google-analytics.com/ga.js';
231+
s.parentNode.insertBefore(g, s);
232+
}(document, 'script'));
235233
</script>
236234
</body>
237235
</html>

doc/logos/index.html

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<p class="twitter"><a href="http://twitter.com/nodejs">@nodejs</a></p>
4141

4242
</div>
43-
43+
4444
<div id="column1" class="interior">
4545
<h2>Logo Downloads</h2>
4646
<table border="0" cellspacing="0" cellpadding="10">
@@ -82,19 +82,17 @@ <h2>Desktop Background</h2>
8282
<li><a href="http://twitter.com/nodejs" class="twitter">@nodejs</a></li>
8383
</ul>
8484

85-
<p>Copyright <a href="http://joyent.com">Joyent, Inc</a>., Node.js is a <a href="/trademark-policy.pdf">trademark of Joyent, Inc</a>., <a href="https://raw.github.com/joyent/node/__VERSION__/LICENSE">View License</a></p>
85+
<p>Copyright <a href="http://joyent.com/">Joyent, Inc</a>., Node.js is a <a href="/trademark-policy.pdf">trademark of Joyent, Inc</a>., <a href="https://raw.github.com/joyent/node/__VERSION__/LICENSE">View License</a></p>
8686
</div>
8787

8888
<script>
89-
var gaJsHost = (("https:" == document.location.protocol) ?
90-
"https://ssl." : "http://www.");
91-
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
92-
</script>
93-
<script type="text/javascript">
94-
try {
95-
var pageTracker = _gat._getTracker("UA-10874194-2");
96-
pageTracker._trackPageview();
97-
} catch(err) {}
89+
window._gaq = [['_setAccount', 'UA-10874194-2'], ['_trackPageview']];
90+
(function(d, t) {
91+
var g = d.createElement(t),
92+
s = d.getElementsByTagName(t)[0];
93+
g.src = '//www.google-analytics.com/ga.js';
94+
s.parentNode.insertBefore(g, s);
95+
}(document, 'script'));
9896
</script>
9997
</body>
10098
</html>

doc/template.html

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,20 @@ <h2>Table of Contents</h2>
6666
<li><a href="http://twitter.com/nodejs" class="twitter">@nodejs</a></li>
6767
</ul>
6868

69-
<p>Copyright <a href="http://joyent.com">Joyent, Inc</a>, Node.js is a <a href="/trademark-policy.pdf">trademark</a> of Joyent, Inc. View <a href="https://raw.github.com/joyent/node/__VERSION__/LICENSE">license</a>.</p>
69+
<p>Copyright <a href="http://joyent.com/">Joyent, Inc</a>, Node.js is a <a href="/trademark-policy.pdf">trademark</a> of Joyent, Inc. View <a href="https://raw.github.com/joyent/node/__VERSION__/LICENSE">license</a>.</p>
7070
</div>
7171

7272
<script src="../sh_main.js"></script>
7373
<script src="../sh_javascript.min.js"></script>
7474
<script>highlight(undefined, undefined, 'pre');</script>
7575
<script>
76-
var gaJsHost = (("https:" == document.location.protocol) ?
77-
"https://ssl." : "http://www.");
78-
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
76+
window._gaq = [['_setAccount', 'UA-10874194-2'], ['_trackPageview']];
77+
(function(d, t) {
78+
var g = d.createElement(t),
79+
s = d.getElementsByTagName(t)[0];
80+
g.src = '//www.google-analytics.com/ga.js';
81+
s.parentNode.insertBefore(g, s);
82+
}(document, 'script'));
7983
</script>
80-
<script>
81-
try {
82-
var pageTracker = _gat._getTracker("UA-10874194-2");
83-
pageTracker._trackPageview();
84-
} catch(err) {}</script>
8584
</body>
8685
</html>

0 commit comments

Comments
 (0)