Skip to content

Commit 68bad51

Browse files
committed
Merge pull request hojberg#17 from Munter/master
Web performance optimizations
2 parents ec0ad81 + f28a8c4 commit 68bad51

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

public/index.html

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ <h2>Arrow configuration</h2>
6767
</footer>
6868

6969
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script>
70-
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
7170
<script type="text/javascript" src="js/vendor/jscolor/jscolor.js"></script>
7271
<link rel="stylesheet" type="text/css" href="js/vendor/jscolor/jscolor.css">
7372

@@ -88,11 +87,28 @@ <h2>Arrow configuration</h2>
8887
_gaq.push(['_trackPageview']);
8988

9089
(function() {
91-
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
92-
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
93-
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
94-
})();
90+
var defer = (function (document, script) {
91+
var urls = [],
92+
firstScript = document.getElementsByTagName(script)[0];
93+
94+
return function (url, callback) {
95+
var inc;
9596

97+
if (url && urls.indexOf(url) === -1) {
98+
inc = document.createElement(script);
99+
inc.async = true;
100+
inc.src = url;
101+
inc.onload = callback || function () {};
102+
firstScript.parentNode.insertBefore(inc, firstScript);
103+
}
104+
}
105+
}(document, 'script'));
106+
107+
window.onload = function () {
108+
defer(('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js');
109+
defer('//platform.twitter.com/widgets.js');
110+
};
111+
})();
96112
</script>
97113
</body>
98114
</html>

0 commit comments

Comments
 (0)