{"action":"created","comment":{"url":"https://api.github.com/repos/guardian/frontend/pulls/comments/39805185","id":39805185,"diff_hunk":"@@ -1,87 +1,163 @@\n @()\n \n-// Duplicated in /static/src/javascripts/projects/common/utils/detect.js\n-// Determine what type of font-hinting we want.\n-\n (function (window, document) {\n-    if (!window.guardian.isModernBrowser) {\n-        return false;\n-    }\n-    var fontHinting = function () {\n-        var ua = navigator.userAgent,\n-            windowsNT = /Windows NT (\\d\\.\\d+)/.exec(ua),\n-            hinting = 'Off',\n-            version;\n-\n-        if (windowsNT) {\n-            version = parseFloat(windowsNT[1], 10);\n-\n-            // For Windows XP-7\n-            if (version >= 5.1 && version <= 6.1) {\n-                if (/Chrome/.exec(ua) && version < 6.0) {\n-                    // Chrome on windows XP wants auto-hinting\n-                    hinting = 'Auto';\n-                } else {\n-                    // All others use cleartype\n-                    hinting = 'Cleartype';\n-                }\n-            }\n-        }\n-        return hinting;\n-    }();\n+    var ua = navigator.userAgent;\n \n-    // Check to see if you should get webfonts, and then try to load them from localStorage if so\n-    var cookieData = 'GU_fonts=off; domain=' + location.hostname + '; path=/';\n-\n-    function disableFonts() {\n-        document.cookie = cookieData + '; max-age=' + (60 * 60 * 24 * 365);\n-    }\n+    // Determine what type of font-hinting we want.\n+    var fontHinting = (function () {\n+        var hinting;\n+        function determineHinting() {\n+            if (typeof hinting === 'undefined') {\n+                try {\n+                    var windowsNT = /Windows NT (\\d\\.\\d+)/.exec(ua),\n+                        version;\n \n-    function enableFonts() {\n-        document.cookie = cookieData + '; expires=Thu, 01 Jan 1970 00:00:00 GMT';\n-    }\n+                    hinting = 'Off';\n+                    if (windowsNT) {\n+                        version = parseFloat(windowsNT[1], 10);\n \n-    function fontsEnabled() {\n-        return document.cookie.indexOf('GU_fonts=off') === -1;\n-    }\n+                        // For Windows XP-7\n+                        if (version >= 5.1 && version <= 6.1) {\n+                            if (/Chrome/.exec(ua) && version < 6.0) {\n+                                // Chrome on windows XP wants auto-hinting\n+                                hinting = 'Auto';\n+                            } else {\n+                                // All others use cleartype\n+                                hinting = 'Cleartype';\n+                            }\n+                        }\n+                    }\n+                } catch (e) {}\n+            }\n+            return hinting;\n+        };\n+        return determineHinting;\n+    })();\n \n     // Load fonts from `localStorage`.\n     function loadFontsFromStorage() {\n-        var storedFontFormat = localStorage['gu.fonts.format'],\n-            fonts, fontFormat, font, dataAttrName, nameAndCacheKey, fontData;\n-\n-        if (storedFontFormat) {\n-            fonts = document.querySelectorAll('.webfont');\n-            fontFormat = JSON.parse(storedFontFormat).value;\n-\n-            for (var i = 0, j = fonts.length; i < j; ++i) {\n-                font = fonts[i];\n-                dataAttrName = 'data-cache-file-' + (fontHinting === 'Off' ? '' : 'hinted-' + fontHinting + '-') + fontFormat;\n-                nameAndCacheKey = font.getAttribute(dataAttrName).match(/fonts\\/([^/]*?)\\/?([^/]*)\\.(woff2|woff|tff).json$/);\n-                fontData = localStorage['gu.fonts.' + nameAndCacheKey[2] + '.' + nameAndCacheKey[1]];\n-\n-                if (fontData) {\n-                    font.innerHTML = JSON.parse(fontData).value;\n-                    font.setAttribute('data-loaded-from', 'local');\n+        try {\n+            if (\"localStorage\" in window) {","path":"common/app/templates/headerInlineJS/loadFonts.scala.js","position":106,"original_position":96,"commit_id":"1c08403c97b2ccd3045a9f424a0d0bf726febfe1","original_commit_id":"89121179f7aa5fd3629de36b0f00a5864c2853de","user":{"login":"jbreckmckye","id":3148617,"avatar_url":"https://avatars.githubusercontent.com/u/3148617?v=3","gravatar_id":"","url":"https://api.github.com/users/jbreckmckye","html_url":"https://github.com/jbreckmckye","followers_url":"https://api.github.com/users/jbreckmckye/followers","following_url":"https://api.github.com/users/jbreckmckye/following{/other_user}","gists_url":"https://api.github.com/users/jbreckmckye/gists{/gist_id}","starred_url":"https://api.github.com/users/jbreckmckye/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbreckmckye/subscriptions","organizations_url":"https://api.github.com/users/jbreckmckye/orgs","repos_url":"https://api.github.com/users/jbreckmckye/repos","events_url":"https://api.github.com/users/jbreckmckye/events{/privacy}","received_events_url":"https://api.github.com/users/jbreckmckye/received_events","type":"User","site_admin":false},"body":"Yes. Unfortunately, there is no standardized exception for storage space exceptions. This is particularly unfortunate when a browser disables localstorage for security purposes by granting it a quota of zero. Therefore your only option becomes _pokémon exception handling_ - you gotta catch 'em all.","created_at":"2015-09-17T22:07:51Z","updated_at":"2015-09-17T22:07:51Z","html_url":"https://github.com/guardian/frontend/pull/10549#discussion_r39805185","pull_request_url":"https://api.github.com/repos/guardian/frontend/pulls/10549","_links":{"self":{"href":"https://api.github.com/repos/guardian/frontend/pulls/comments/39805185"},"html":{"href":"https://github.com/guardian/frontend/pull/10549#discussion_r39805185"},"pull_request":{"href":"https://api.github.com/repos/guardian/frontend/pulls/10549"}}},"pull_request":{"url":"https://api.github.com/repos/guardian/frontend/pulls/10549","id":45278270,"html_url":"https://github.com/guardian/frontend/pull/10549","diff_url":"https://github.com/guardian/frontend/pull/10549.diff","patch_url":"https://github.com/guardian/frontend/pull/10549.patch","issue_url":"https://api.github.com/repos/guardian/frontend/issues/10549","number":10549,"state":"open","locked":false,"title":"Fonts everywhere","user":{"login":"sndrs","id":867233,"avatar_url":"https://avatars.githubusercontent.com/u/867233?v=3","gravatar_id":"","url":"https://api.github.com/users/sndrs","html_url":"https://github.com/sndrs","followers_url":"https://api.github.com/users/sndrs/followers","following_url":"https://api.github.com/users/sndrs/following{/other_user}","gists_url":"https://api.github.com/users/sndrs/gists{/gist_id}","starred_url":"https://api.github.com/users/sndrs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sndrs/subscriptions","organizations_url":"https://api.github.com/users/sndrs/orgs","repos_url":"https://api.github.com/users/sndrs/repos","events_url":"https://api.github.com/users/sndrs/events{/privacy}","received_events_url":"https://api.github.com/users/sndrs/received_events","type":"User","site_admin":false},"body":"Moves font loading outside of `isModernBrowser`.\r\n\r\ncore:\r\n![screen shot 2015-09-17 at 15 04 03](https://cloud.githubusercontent.com/assets/867233/9935283/a0bba9b8-5d4d-11e5-8e50-6d0efb1865d8.png)\r\n\r\nfull app:\r\n![screen shot 2015-09-17 at 15 05 47](https://cloud.githubusercontent.com/assets/867233/9935285/a6ad4ffc-5d4d-11e5-9844-de6a8fff4dcf.png)\r\n\r\nPreviously, the logic went:\r\n- `isModernBrowser`?\r\n - yes – have fonts in `localStorage`?\r\n   - yes – inject them\r\n    - no – did the `localStorage` check go ok?\r\n      - yes – when the main app runs it will ajax them in as JSON, inject them and save them to `localStorage`  \r\n      - no – load font files async using `@font-face`\r\n - no – do nothing\r\n\r\nNow it goes:\r\n- have fonts in `localStorage`?\r\n - yes – inject them\r\n - no – did the `localStorage` check go ok?\r\n   - yes – ajax them in as JSON immediately, inject them and save them to `localStorage`\r\n    - no – load font files async using `@font-face`\r\n\r\nnote that this still requires JS though - there's no way to download webfonts without blocking text rendering without  some JS finagling (in the worst case, safari will wait 60s for a fonts with nothing rendered, then discard then even when it _does_ arrive).\r\n\r\n### Screenshots\r\ncore: https://www.browserstack.com/screenshots/d0d4840598fcd5b3ff86d20e626b80d787240bd3\r\nfull app: https://www.browserstack.com/screenshots/21ab2e082b944544b0f8fe4d46ff354ba0ae3bd5\r\n\r\n### Testing\r\n- [ ] check fonts load ok, especially in android? there's issues in the screenshots but suspect it's just browsersync's emulator","created_at":"2015-09-17T11:14:21Z","updated_at":"2015-09-17T22:07:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3ca7bb4a0646ee55092f40b6ed624149adcb9e10","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/guardian/frontend/pulls/10549/commits","review_comments_url":"https://api.github.com/repos/guardian/frontend/pulls/10549/comments","review_comment_url":"https://api.github.com/repos/guardian/frontend/pulls/comments{/number}","comments_url":"https://api.github.com/repos/guardian/frontend/issues/10549/comments","statuses_url":"https://api.github.com/repos/guardian/frontend/statuses/1c08403c97b2ccd3045a9f424a0d0bf726febfe1","head":{"label":"guardian:fonts-everywhere","ref":"fonts-everywhere","sha":"1c08403c97b2ccd3045a9f424a0d0bf726febfe1","user":{"login":"guardian","id":164318,"avatar_url":"https://avatars.githubusercontent.com/u/164318?v=3","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"repo":{"id":4370755,"name":"frontend","full_name":"guardian/frontend","owner":{"login":"guardian","id":164318,"avatar_url":"https://avatars.githubusercontent.com/u/164318?v=3","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/guardian/frontend","description":"Source for theguardian.com","fork":false,"url":"https://api.github.com/repos/guardian/frontend","forks_url":"https://api.github.com/repos/guardian/frontend/forks","keys_url":"https://api.github.com/repos/guardian/frontend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/guardian/frontend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/guardian/frontend/teams","hooks_url":"https://api.github.com/repos/guardian/frontend/hooks","issue_events_url":"https://api.github.com/repos/guardian/frontend/issues/events{/number}","events_url":"https://api.github.com/repos/guardian/frontend/events","assignees_url":"https://api.github.com/repos/guardian/frontend/assignees{/user}","branches_url":"https://api.github.com/repos/guardian/frontend/branches{/branch}","tags_url":"https://api.github.com/repos/guardian/frontend/tags","blobs_url":"https://api.github.com/repos/guardian/frontend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/guardian/frontend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/guardian/frontend/git/refs{/sha}","trees_url":"https://api.github.com/repos/guardian/frontend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/guardian/frontend/statuses/{sha}","languages_url":"https://api.github.com/repos/guardian/frontend/languages","stargazers_url":"https://api.github.com/repos/guardian/frontend/stargazers","contributors_url":"https://api.github.com/repos/guardian/frontend/contributors","subscribers_url":"https://api.github.com/repos/guardian/frontend/subscribers","subscription_url":"https://api.github.com/repos/guardian/frontend/subscription","commits_url":"https://api.github.com/repos/guardian/frontend/commits{/sha}","git_commits_url":"https://api.github.com/repos/guardian/frontend/git/commits{/sha}","comments_url":"https://api.github.com/repos/guardian/frontend/comments{/number}","issue_comment_url":"https://api.github.com/repos/guardian/frontend/issues/comments{/number}","contents_url":"https://api.github.com/repos/guardian/frontend/contents/{+path}","compare_url":"https://api.github.com/repos/guardian/frontend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/guardian/frontend/merges","archive_url":"https://api.github.com/repos/guardian/frontend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/guardian/frontend/downloads","issues_url":"https://api.github.com/repos/guardian/frontend/issues{/number}","pulls_url":"https://api.github.com/repos/guardian/frontend/pulls{/number}","milestones_url":"https://api.github.com/repos/guardian/frontend/milestones{/number}","notifications_url":"https://api.github.com/repos/guardian/frontend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/guardian/frontend/labels{/name}","releases_url":"https://api.github.com/repos/guardian/frontend/releases{/id}","created_at":"2012-05-18T15:39:15Z","updated_at":"2015-09-17T00:23:22Z","pushed_at":"2015-09-17T17:08:15Z","git_url":"git://github.com/guardian/frontend.git","ssh_url":"git@github.com:guardian/frontend.git","clone_url":"https://github.com/guardian/frontend.git","svn_url":"https://github.com/guardian/frontend","homepage":"http://www.theguardian.com","size":512585,"stargazers_count":2936,"watchers_count":2936,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":282,"mirror_url":null,"open_issues_count":73,"forks":282,"open_issues":73,"watchers":2936,"default_branch":"master"}},"base":{"label":"guardian:master","ref":"master","sha":"ec1f183258f957b11632fdaf280e7e7e9fd908c6","user":{"login":"guardian","id":164318,"avatar_url":"https://avatars.githubusercontent.com/u/164318?v=3","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"repo":{"id":4370755,"name":"frontend","full_name":"guardian/frontend","owner":{"login":"guardian","id":164318,"avatar_url":"https://avatars.githubusercontent.com/u/164318?v=3","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/guardian/frontend","description":"Source for theguardian.com","fork":false,"url":"https://api.github.com/repos/guardian/frontend","forks_url":"https://api.github.com/repos/guardian/frontend/forks","keys_url":"https://api.github.com/repos/guardian/frontend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/guardian/frontend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/guardian/frontend/teams","hooks_url":"https://api.github.com/repos/guardian/frontend/hooks","issue_events_url":"https://api.github.com/repos/guardian/frontend/issues/events{/number}","events_url":"https://api.github.com/repos/guardian/frontend/events","assignees_url":"https://api.github.com/repos/guardian/frontend/assignees{/user}","branches_url":"https://api.github.com/repos/guardian/frontend/branches{/branch}","tags_url":"https://api.github.com/repos/guardian/frontend/tags","blobs_url":"https://api.github.com/repos/guardian/frontend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/guardian/frontend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/guardian/frontend/git/refs{/sha}","trees_url":"https://api.github.com/repos/guardian/frontend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/guardian/frontend/statuses/{sha}","languages_url":"https://api.github.com/repos/guardian/frontend/languages","stargazers_url":"https://api.github.com/repos/guardian/frontend/stargazers","contributors_url":"https://api.github.com/repos/guardian/frontend/contributors","subscribers_url":"https://api.github.com/repos/guardian/frontend/subscribers","subscription_url":"https://api.github.com/repos/guardian/frontend/subscription","commits_url":"https://api.github.com/repos/guardian/frontend/commits{/sha}","git_commits_url":"https://api.github.com/repos/guardian/frontend/git/commits{/sha}","comments_url":"https://api.github.com/repos/guardian/frontend/comments{/number}","issue_comment_url":"https://api.github.com/repos/guardian/frontend/issues/comments{/number}","contents_url":"https://api.github.com/repos/guardian/frontend/contents/{+path}","compare_url":"https://api.github.com/repos/guardian/frontend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/guardian/frontend/merges","archive_url":"https://api.github.com/repos/guardian/frontend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/guardian/frontend/downloads","issues_url":"https://api.github.com/repos/guardian/frontend/issues{/number}","pulls_url":"https://api.github.com/repos/guardian/frontend/pulls{/number}","milestones_url":"https://api.github.com/repos/guardian/frontend/milestones{/number}","notifications_url":"https://api.github.com/repos/guardian/frontend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/guardian/frontend/labels{/name}","releases_url":"https://api.github.com/repos/guardian/frontend/releases{/id}","created_at":"2012-05-18T15:39:15Z","updated_at":"2015-09-17T00:23:22Z","pushed_at":"2015-09-17T17:08:15Z","git_url":"git://github.com/guardian/frontend.git","ssh_url":"git@github.com:guardian/frontend.git","clone_url":"https://github.com/guardian/frontend.git","svn_url":"https://github.com/guardian/frontend","homepage":"http://www.theguardian.com","size":512585,"stargazers_count":2936,"watchers_count":2936,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":282,"mirror_url":null,"open_issues_count":73,"forks":282,"open_issues":73,"watchers":2936,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/guardian/frontend/pulls/10549"},"html":{"href":"https://github.com/guardian/frontend/pull/10549"},"issue":{"href":"https://api.github.com/repos/guardian/frontend/issues/10549"},"comments":{"href":"https://api.github.com/repos/guardian/frontend/issues/10549/comments"},"review_comments":{"href":"https://api.github.com/repos/guardian/frontend/pulls/10549/comments"},"review_comment":{"href":"https://api.github.com/repos/guardian/frontend/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/guardian/frontend/pulls/10549/commits"},"statuses":{"href":"https://api.github.com/repos/guardian/frontend/statuses/1c08403c97b2ccd3045a9f424a0d0bf726febfe1"}}}}