{"action":"created","issue":{"url":"https://api.github.com/repos/tulios/json-viewer/issues/142","repository_url":"https://api.github.com/repos/tulios/json-viewer","labels_url":"https://api.github.com/repos/tulios/json-viewer/issues/142/labels{/name}","comments_url":"https://api.github.com/repos/tulios/json-viewer/issues/142/comments","events_url":"https://api.github.com/repos/tulios/json-viewer/issues/142/events","html_url":"https://github.com/tulios/json-viewer/issues/142","id":206074770,"number":142,"title":"50ms JS parse time on non-json pages","user":{"login":"matthewoates","id":3092315,"avatar_url":"https://avatars.githubusercontent.com/u/3092315?v=3","gravatar_id":"","url":"https://api.github.com/users/matthewoates","html_url":"https://github.com/matthewoates","followers_url":"https://api.github.com/users/matthewoates/followers","following_url":"https://api.github.com/users/matthewoates/following{/other_user}","gists_url":"https://api.github.com/users/matthewoates/gists{/gist_id}","starred_url":"https://api.github.com/users/matthewoates/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthewoates/subscriptions","organizations_url":"https://api.github.com/users/matthewoates/orgs","repos_url":"https://api.github.com/users/matthewoates/repos","events_url":"https://api.github.com/users/matthewoates/events{/privacy}","received_events_url":"https://api.github.com/users/matthewoates/received_events","type":"User","site_admin":false},"labels":[{"id":55224589,"url":"https://api.github.com/repos/tulios/json-viewer/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-02-08T02:06:53Z","updated_at":"2017-02-08T18:09:22Z","closed_at":null,"body":"This extension adds ~50ms of JS execution time for each page. There should be a lightweight script that checks if there is JSON on the page before loading and parsing the larger script.\r\n\r\nNote `viewer.js` is running for 50ms.\r\n<img width=\"832\" alt=\"screen shot 2017-02-07 at 6 05 25 pm\" src=\"https://cloud.githubusercontent.com/assets/3092315/22720522/2b74226c-ed60-11e6-8229-375cec993768.png\">\r\n"},"comment":{"url":"https://api.github.com/repos/tulios/json-viewer/issues/comments/278413006","html_url":"https://github.com/tulios/json-viewer/issues/142#issuecomment-278413006","issue_url":"https://api.github.com/repos/tulios/json-viewer/issues/142","id":278413006,"user":{"login":"matthewoates","id":3092315,"avatar_url":"https://avatars.githubusercontent.com/u/3092315?v=3","gravatar_id":"","url":"https://api.github.com/users/matthewoates","html_url":"https://github.com/matthewoates","followers_url":"https://api.github.com/users/matthewoates/followers","following_url":"https://api.github.com/users/matthewoates/following{/other_user}","gists_url":"https://api.github.com/users/matthewoates/gists{/gist_id}","starred_url":"https://api.github.com/users/matthewoates/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthewoates/subscriptions","organizations_url":"https://api.github.com/users/matthewoates/orgs","repos_url":"https://api.github.com/users/matthewoates/repos","events_url":"https://api.github.com/users/matthewoates/events{/privacy}","received_events_url":"https://api.github.com/users/matthewoates/received_events","type":"User","site_admin":false},"created_at":"2017-02-08T18:09:22Z","updated_at":"2017-02-08T18:09:22Z","body":"Sweet. Another idea:\r\n\r\nSince this runs at the start of every single page load, something like a series of checks sounds best instead of trying to parse the body.\r\n\r\nSomething like:\r\n\r\n```\r\nfunction isJSON(str) {\r\n  return str\r\n    && firstCharacterIsOpenBrace(str)\r\n    && isValidJSON(str);\r\n}\r\n```\r\n\r\nThe `firstCharacterIsOpenBrace` check (plus some additional lightweight logic for JSONP support) is a very performant way to short-circuit 99.9% of pages that aren't JSON.\r\n\r\nOf course, my first suggestion as opposed to the suggestion in this comment will yield a much larger performance boost."}}
{"actor":{"display_login":"matthewoates"}}