{"action":"created","comment":{"url":"https://api.github.com/repos/h5bp/html5-boilerplate/pulls/comments/24227679","id":24227679,"diff_hunk":"@@ -29,11 +29,10 @@\n \n         <!-- Google Analytics: change UA-XXXXX-X to be your site's ID. -->\n         <script>\n-            (function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=\n-            function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date;\n-            e=o.createElement(i);r=o.getElementsByTagName(i)[0];\n-            e.src='//www.google-analytics.com/analytics.js';\n-            r.parentNode.insertBefore(e,r)}(window,document,'script','ga'));\n+            (function(b,o,i,l){GoogleAnalyticsObject=l;(b[l]=b[l]||\n+            function(){(b[l].q=b[l].q||[]).push(arguments)}).l=+new Date;\n+            o.getElementsByTagName(i)[0].parentNode.appendChild(o.createElement(i))\n+            .src='//www.google-analytics.com/analytics.js'}(window,document,'script','ga'));","path":"dist/index.html","position":12,"original_position":12,"commit_id":"a3fdbb5551131ab5885a273abd11c860df07f271","original_commit_id":"a3fdbb5551131ab5885a273abd11c860df07f271","user":{"login":"mathiasbynens","id":81942,"avatar_url":"https://avatars.githubusercontent.com/u/81942?v=3","gravatar_id":"","url":"https://api.github.com/users/mathiasbynens","html_url":"https://github.com/mathiasbynens","followers_url":"https://api.github.com/users/mathiasbynens/followers","following_url":"https://api.github.com/users/mathiasbynens/following{/other_user}","gists_url":"https://api.github.com/users/mathiasbynens/gists{/gist_id}","starred_url":"https://api.github.com/users/mathiasbynens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mathiasbynens/subscriptions","organizations_url":"https://api.github.com/users/mathiasbynens/orgs","repos_url":"https://api.github.com/users/mathiasbynens/repos","events_url":"https://api.github.com/users/mathiasbynens/events{/privacy}","received_events_url":"https://api.github.com/users/mathiasbynens/received_events","type":"User","site_admin":false},"body":"Let’s make this a hardcoded `https://` for the reasons outlined here: https://github.com/konklone/cdns-to-https#conclusion-cdns-should-redirect-to-https. This is a change everyone will agree on. (Perhaps I should open a separate PR for it?)\r\n\r\nThe other changes are open to bikeshedding :)","created_at":"2015-02-06T08:22:08Z","updated_at":"2015-02-06T08:22:08Z","html_url":"https://github.com/h5bp/html5-boilerplate/pull/1660#discussion_r24227679","pull_request_url":"https://api.github.com/repos/h5bp/html5-boilerplate/pulls/1660","_links":{"self":{"href":"https://api.github.com/repos/h5bp/html5-boilerplate/pulls/comments/24227679"},"html":{"href":"https://github.com/h5bp/html5-boilerplate/pull/1660#discussion_r24227679"},"pull_request":{"href":"https://api.github.com/repos/h5bp/html5-boilerplate/pulls/1660"}}},"pull_request":{"url":"https://api.github.com/repos/h5bp/html5-boilerplate/pulls/1660","id":27366879,"html_url":"https://github.com/h5bp/html5-boilerplate/pull/1660","diff_url":"https://github.com/h5bp/html5-boilerplate/pull/1660.diff","patch_url":"https://github.com/h5bp/html5-boilerplate/pull/1660.patch","issue_url":"https://api.github.com/repos/h5bp/html5-boilerplate/issues/1660","number":1660,"state":"open","locked":false,"title":"Further optimizing Google Analytics snippet","user":{"login":"BLooperZ","id":10459948,"avatar_url":"https://avatars.githubusercontent.com/u/10459948?v=3","gravatar_id":"","url":"https://api.github.com/users/BLooperZ","html_url":"https://github.com/BLooperZ","followers_url":"https://api.github.com/users/BLooperZ/followers","following_url":"https://api.github.com/users/BLooperZ/following{/other_user}","gists_url":"https://api.github.com/users/BLooperZ/gists{/gist_id}","starred_url":"https://api.github.com/users/BLooperZ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BLooperZ/subscriptions","organizations_url":"https://api.github.com/users/BLooperZ/orgs","repos_url":"https://api.github.com/users/BLooperZ/repos","events_url":"https://api.github.com/users/BLooperZ/events{/privacy}","received_events_url":"https://api.github.com/users/BLooperZ/received_events","type":"User","site_admin":false},"body":"__EDIT__: it started to be a real mess in this post so i cleared it up\r\n\r\nthis is a shorter (and still safe) version of the google analytics snippet - 322 charcters against 346\r\nit does exactly the same - except adding the script after the first script in the document rather than before it. only one function changed - `insertBefore` to `appendChild` to eliminate the need for one of the parameters, all the rest is done by syntax manipulation __ONLY__\r\nthis is a bit more readable version (same code just added whitespace:\r\n```\r\n(function (b, o, i, l) {\r\n    GoogleAnalyticsObject = l;\r\n    (b[l] = b[l] || function () {\r\n        (b[l].q = b[l].q || []).push(arguments)}\r\n    ).l = +new Date;\r\n    o.getElementsByTagName(i)[0].parentNode.appendChild(o.createElement(i)).src='//www.google-analytics.com/analytics.js'}\r\n(window, document, 'script', 'ga'));ga('create', 'UA-XXXXX-X', 'auto');ga('send', 'pageview');\r\n```\r\nlet go line by line:\r\n__new__ `(function (b, o, i, l) {` __old__ `(function(b,o,i,l,e,r)`\r\nnot much to say we need less parameters\r\n__new__ `GoogleAnalyticsObject = l;` __old__ `b.GoogleAnalyticsObject=l;`\r\nthe window object is assumed if no object specified (except for conditional statements)\r\n__new__ `(b[l] = b[l] || function () {` __old__ `b[l] || (b[l] = function () {`\r\nshorter syntax and we can use it 2 lines later\r\n__new__ `(b[l].q = b[l].q || []).push(arguments)}` __old__ `(b[l].q = b[l].q || []).push(arguments)}`\r\nno change here\r\n__new__ `).l = +new Date;` __old__ `);b[l].l = +new Date;`\r\nwe use the functio0n it self as the object instead of referencing it\r\n__new__ \r\n```\r\no.getElementsByTagName(i)[0].parentNode.appendChild(o.createElement(i)).src='//www.google-analytics.com/analytics.js'}\r\n```\r\n__old__ \r\n```\r\ne=o.createElement(i);r=o.getElementsByTagName(i)[0];\r\ne.src='//www.google-analytics.com/analytics.js';\r\nr.parentNode.insertBefore(e,r)}\r\n```\r\nby changing to appendChild we do not need reference anymore and we declare anything inside the functions - using the original value and saving the need for a parameter\r\n__new__ `(window, document, 'script', 'ga'));ga('create', 'UA-XXXXX-X', 'auto');ga('send', 'pageview');` __old__ `(window, document, 'script', 'ga'));ga('create','UA-XXXXX-X','auto');ga('send','pageview');`\r\nalso the same\r\n\r\nI've checked this script with google analytics debugger, also with multiple trackers\r\nit works (no reason why not)\r\n@mathiasbynens - feel free to update your article about it if you like\r\n","created_at":"2015-01-14T17:23:41Z","updated_at":"2015-02-06T08:22:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"054f30ceb2ac46dda03000773c13ad5d59f41119","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/h5bp/html5-boilerplate/pulls/1660/commits","review_comments_url":"https://api.github.com/repos/h5bp/html5-boilerplate/pulls/1660/comments","review_comment_url":"https://api.github.com/repos/h5bp/html5-boilerplate/pulls/comments/{number}","comments_url":"https://api.github.com/repos/h5bp/html5-boilerplate/issues/1660/comments","statuses_url":"https://api.github.com/repos/h5bp/html5-boilerplate/statuses/a3fdbb5551131ab5885a273abd11c860df07f271","head":{"label":"BLooperZ:patch-1","ref":"patch-1","sha":"a3fdbb5551131ab5885a273abd11c860df07f271","user":{"login":"BLooperZ","id":10459948,"avatar_url":"https://avatars.githubusercontent.com/u/10459948?v=3","gravatar_id":"","url":"https://api.github.com/users/BLooperZ","html_url":"https://github.com/BLooperZ","followers_url":"https://api.github.com/users/BLooperZ/followers","following_url":"https://api.github.com/users/BLooperZ/following{/other_user}","gists_url":"https://api.github.com/users/BLooperZ/gists{/gist_id}","starred_url":"https://api.github.com/users/BLooperZ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BLooperZ/subscriptions","organizations_url":"https://api.github.com/users/BLooperZ/orgs","repos_url":"https://api.github.com/users/BLooperZ/repos","events_url":"https://api.github.com/users/BLooperZ/events{/privacy}","received_events_url":"https://api.github.com/users/BLooperZ/received_events","type":"User","site_admin":false},"repo":{"id":29255856,"name":"html5-boilerplate","full_name":"BLooperZ/html5-boilerplate","owner":{"login":"BLooperZ","id":10459948,"avatar_url":"https://avatars.githubusercontent.com/u/10459948?v=3","gravatar_id":"","url":"https://api.github.com/users/BLooperZ","html_url":"https://github.com/BLooperZ","followers_url":"https://api.github.com/users/BLooperZ/followers","following_url":"https://api.github.com/users/BLooperZ/following{/other_user}","gists_url":"https://api.github.com/users/BLooperZ/gists{/gist_id}","starred_url":"https://api.github.com/users/BLooperZ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BLooperZ/subscriptions","organizations_url":"https://api.github.com/users/BLooperZ/orgs","repos_url":"https://api.github.com/users/BLooperZ/repos","events_url":"https://api.github.com/users/BLooperZ/events{/privacy}","received_events_url":"https://api.github.com/users/BLooperZ/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/BLooperZ/html5-boilerplate","description":"A professional front-end template for building fast, robust, and adaptable web apps or sites.","fork":true,"url":"https://api.github.com/repos/BLooperZ/html5-boilerplate","forks_url":"https://api.github.com/repos/BLooperZ/html5-boilerplate/forks","keys_url":"https://api.github.com/repos/BLooperZ/html5-boilerplate/keys{/key_id}","collaborators_url":"https://api.github.com/repos/BLooperZ/html5-boilerplate/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/BLooperZ/html5-boilerplate/teams","hooks_url":"https://api.github.com/repos/BLooperZ/html5-boilerplate/hooks","issue_events_url":"https://api.github.com/repos/BLooperZ/html5-boilerplate/issues/events{/number}","events_url":"https://api.github.com/repos/BLooperZ/html5-boilerplate/events","assignees_url":"https://api.github.com/repos/BLooperZ/html5-boilerplate/assignees{/user}","branches_url":"https://api.github.com/repos/BLooperZ/html5-boilerplate/branches{/branch}","tags_url":"https://api.github.com/repos/BLooperZ/html5-boilerplate/tags","blobs_url":"https://api.github.com/repos/BLooperZ/html5-boilerplate/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/BLooperZ/html5-boilerplate/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/BLooperZ/html5-boilerplate/git/refs{/sha}","trees_url":"https://api.github.com/repos/BLooperZ/html5-boilerplate/git/trees{/sha}","statuses_url":"https://api.github.com/repos/BLooperZ/html5-boilerplate/statuses/{sha}","languages_url":"https://api.github.com/repos/BLooperZ/html5-boilerplate/languages","stargazers_url":"https://api.github.com/repos/BLooperZ/html5-boilerplate/stargazers","contributors_url":"https://api.github.com/repos/BLooperZ/html5-boilerplate/contributors","subscribers_url":"https://api.github.com/repos/BLooperZ/html5-boilerplate/subscribers","subscription_url":"https://api.github.com/repos/BLooperZ/html5-boilerplate/subscription","commits_url":"https://api.github.com/repos/BLooperZ/html5-boilerplate/commits{/sha}","git_commits_url":"https://api.github.com/repos/BLooperZ/html5-boilerplate/git/commits{/sha}","comments_url":"https://api.github.com/repos/BLooperZ/html5-boilerplate/comments{/number}","issue_comment_url":"https://api.github.com/repos/BLooperZ/html5-boilerplate/issues/comments/{number}","contents_url":"https://api.github.com/repos/BLooperZ/html5-boilerplate/contents/{+path}","compare_url":"https://api.github.com/repos/BLooperZ/html5-boilerplate/compare/{base}...{head}","merges_url":"https://api.github.com/repos/BLooperZ/html5-boilerplate/merges","archive_url":"https://api.github.com/repos/BLooperZ/html5-boilerplate/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/BLooperZ/html5-boilerplate/downloads","issues_url":"https://api.github.com/repos/BLooperZ/html5-boilerplate/issues{/number}","pulls_url":"https://api.github.com/repos/BLooperZ/html5-boilerplate/pulls{/number}","milestones_url":"https://api.github.com/repos/BLooperZ/html5-boilerplate/milestones{/number}","notifications_url":"https://api.github.com/repos/BLooperZ/html5-boilerplate/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/BLooperZ/html5-boilerplate/labels{/name}","releases_url":"https://api.github.com/repos/BLooperZ/html5-boilerplate/releases{/id}","created_at":"2015-01-14T17:16:24Z","updated_at":"2015-01-14T17:16:26Z","pushed_at":"2015-02-02T10:07:55Z","git_url":"git://github.com/BLooperZ/html5-boilerplate.git","ssh_url":"git@github.com:BLooperZ/html5-boilerplate.git","clone_url":"https://github.com/BLooperZ/html5-boilerplate.git","svn_url":"https://github.com/BLooperZ/html5-boilerplate","homepage":"http://html5boilerplate.com/","size":13009,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"h5bp:master","ref":"master","sha":"db639fd0ec54da3d9fc6407de5f7b7a0b7e8b1c8","user":{"login":"h5bp","id":1136800,"avatar_url":"https://avatars.githubusercontent.com/u/1136800?v=3","gravatar_id":"","url":"https://api.github.com/users/h5bp","html_url":"https://github.com/h5bp","followers_url":"https://api.github.com/users/h5bp/followers","following_url":"https://api.github.com/users/h5bp/following{/other_user}","gists_url":"https://api.github.com/users/h5bp/gists{/gist_id}","starred_url":"https://api.github.com/users/h5bp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/h5bp/subscriptions","organizations_url":"https://api.github.com/users/h5bp/orgs","repos_url":"https://api.github.com/users/h5bp/repos","events_url":"https://api.github.com/users/h5bp/events{/privacy}","received_events_url":"https://api.github.com/users/h5bp/received_events","type":"Organization","site_admin":false},"repo":{"id":486550,"name":"html5-boilerplate","full_name":"h5bp/html5-boilerplate","owner":{"login":"h5bp","id":1136800,"avatar_url":"https://avatars.githubusercontent.com/u/1136800?v=3","gravatar_id":"","url":"https://api.github.com/users/h5bp","html_url":"https://github.com/h5bp","followers_url":"https://api.github.com/users/h5bp/followers","following_url":"https://api.github.com/users/h5bp/following{/other_user}","gists_url":"https://api.github.com/users/h5bp/gists{/gist_id}","starred_url":"https://api.github.com/users/h5bp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/h5bp/subscriptions","organizations_url":"https://api.github.com/users/h5bp/orgs","repos_url":"https://api.github.com/users/h5bp/repos","events_url":"https://api.github.com/users/h5bp/events{/privacy}","received_events_url":"https://api.github.com/users/h5bp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/h5bp/html5-boilerplate","description":"A professional front-end template for building fast, robust, and adaptable web apps or sites.","fork":false,"url":"https://api.github.com/repos/h5bp/html5-boilerplate","forks_url":"https://api.github.com/repos/h5bp/html5-boilerplate/forks","keys_url":"https://api.github.com/repos/h5bp/html5-boilerplate/keys{/key_id}","collaborators_url":"https://api.github.com/repos/h5bp/html5-boilerplate/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/h5bp/html5-boilerplate/teams","hooks_url":"https://api.github.com/repos/h5bp/html5-boilerplate/hooks","issue_events_url":"https://api.github.com/repos/h5bp/html5-boilerplate/issues/events{/number}","events_url":"https://api.github.com/repos/h5bp/html5-boilerplate/events","assignees_url":"https://api.github.com/repos/h5bp/html5-boilerplate/assignees{/user}","branches_url":"https://api.github.com/repos/h5bp/html5-boilerplate/branches{/branch}","tags_url":"https://api.github.com/repos/h5bp/html5-boilerplate/tags","blobs_url":"https://api.github.com/repos/h5bp/html5-boilerplate/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/h5bp/html5-boilerplate/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/h5bp/html5-boilerplate/git/refs{/sha}","trees_url":"https://api.github.com/repos/h5bp/html5-boilerplate/git/trees{/sha}","statuses_url":"https://api.github.com/repos/h5bp/html5-boilerplate/statuses/{sha}","languages_url":"https://api.github.com/repos/h5bp/html5-boilerplate/languages","stargazers_url":"https://api.github.com/repos/h5bp/html5-boilerplate/stargazers","contributors_url":"https://api.github.com/repos/h5bp/html5-boilerplate/contributors","subscribers_url":"https://api.github.com/repos/h5bp/html5-boilerplate/subscribers","subscription_url":"https://api.github.com/repos/h5bp/html5-boilerplate/subscription","commits_url":"https://api.github.com/repos/h5bp/html5-boilerplate/commits{/sha}","git_commits_url":"https://api.github.com/repos/h5bp/html5-boilerplate/git/commits{/sha}","comments_url":"https://api.github.com/repos/h5bp/html5-boilerplate/comments{/number}","issue_comment_url":"https://api.github.com/repos/h5bp/html5-boilerplate/issues/comments/{number}","contents_url":"https://api.github.com/repos/h5bp/html5-boilerplate/contents/{+path}","compare_url":"https://api.github.com/repos/h5bp/html5-boilerplate/compare/{base}...{head}","merges_url":"https://api.github.com/repos/h5bp/html5-boilerplate/merges","archive_url":"https://api.github.com/repos/h5bp/html5-boilerplate/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/h5bp/html5-boilerplate/downloads","issues_url":"https://api.github.com/repos/h5bp/html5-boilerplate/issues{/number}","pulls_url":"https://api.github.com/repos/h5bp/html5-boilerplate/pulls{/number}","milestones_url":"https://api.github.com/repos/h5bp/html5-boilerplate/milestones{/number}","notifications_url":"https://api.github.com/repos/h5bp/html5-boilerplate/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/h5bp/html5-boilerplate/labels{/name}","releases_url":"https://api.github.com/repos/h5bp/html5-boilerplate/releases{/id}","created_at":"2010-01-24T18:03:24Z","updated_at":"2015-02-06T07:17:24Z","pushed_at":"2015-02-02T18:09:34Z","git_url":"git://github.com/h5bp/html5-boilerplate.git","ssh_url":"git@github.com:h5bp/html5-boilerplate.git","clone_url":"https://github.com/h5bp/html5-boilerplate.git","svn_url":"https://github.com/h5bp/html5-boilerplate","homepage":"https://html5boilerplate.com/","size":65021,"stargazers_count":28425,"watchers_count":28425,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7387,"mirror_url":null,"open_issues_count":12,"forks":7387,"open_issues":12,"watchers":28425,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/h5bp/html5-boilerplate/pulls/1660"},"html":{"href":"https://github.com/h5bp/html5-boilerplate/pull/1660"},"issue":{"href":"https://api.github.com/repos/h5bp/html5-boilerplate/issues/1660"},"comments":{"href":"https://api.github.com/repos/h5bp/html5-boilerplate/issues/1660/comments"},"review_comments":{"href":"https://api.github.com/repos/h5bp/html5-boilerplate/pulls/1660/comments"},"review_comment":{"href":"https://api.github.com/repos/h5bp/html5-boilerplate/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/h5bp/html5-boilerplate/pulls/1660/commits"},"statuses":{"href":"https://api.github.com/repos/h5bp/html5-boilerplate/statuses/a3fdbb5551131ab5885a273abd11c860df07f271"}}}}