{"action":"created","issue":{"url":"https://api.github.com/repos/w3c/resource-hints/issues/36","labels_url":"https://api.github.com/repos/w3c/resource-hints/issues/36/labels{/name}","comments_url":"https://api.github.com/repos/w3c/resource-hints/issues/36/comments","events_url":"https://api.github.com/repos/w3c/resource-hints/issues/36/events","html_url":"https://github.com/w3c/resource-hints/issues/36","id":88908523,"number":36,"title":"prebrowsing javascript api","user":{"login":"Jxck","id":322289,"avatar_url":"https://avatars.githubusercontent.com/u/322289?v=3","gravatar_id":"","url":"https://api.github.com/users/Jxck","html_url":"https://github.com/Jxck","followers_url":"https://api.github.com/users/Jxck/followers","following_url":"https://api.github.com/users/Jxck/following{/other_user}","gists_url":"https://api.github.com/users/Jxck/gists{/gist_id}","starred_url":"https://api.github.com/users/Jxck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Jxck/subscriptions","organizations_url":"https://api.github.com/users/Jxck/orgs","repos_url":"https://api.github.com/users/Jxck/repos","events_url":"https://api.github.com/users/Jxck/events{/privacy}","received_events_url":"https://api.github.com/users/Jxck/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2015-06-17T04:27:09Z","updated_at":"2015-06-19T01:04:12Z","closed_at":null,"body":"like single page application, there cause lots of dynamic fetch request from javascript.\r\nbut if we need to optimize them using pre-*.\r\n\r\nwe need to scan all javascript source and apply to html as link tag,\r\nor create link element from javascript and add it to dom.\r\n\r\nI think it's helpful to export javascript API for pre-*\r\nwe don't need to care about sync with dom link tag,\r\nand complete in javascript source.\r\n\r\nfor example\r\nin case of send a request with search query and fetch result.\r\nwe can pre-connect to search server while user inputs query.\r\n\r\nlike rails turbo-links style pjax.\r\nprefetch, prerender will fit.\r\n\r\nI think someone says service worker + fetch + cache will help.\r\nbut we can't do preconnect, we don't wanna send http request.\r\nwe also can't do prerender, service worker doesn't render it.\r\nprefetch seems work, but we need to write heavy code and register to browser.\r\neasy way for enable them to browser API are welcome. "},"comment":{"url":"https://api.github.com/repos/w3c/resource-hints/issues/comments/113332866","html_url":"https://github.com/w3c/resource-hints/issues/36#issuecomment-113332866","issue_url":"https://api.github.com/repos/w3c/resource-hints/issues/36","id":113332866,"user":{"login":"Jxck","id":322289,"avatar_url":"https://avatars.githubusercontent.com/u/322289?v=3","gravatar_id":"","url":"https://api.github.com/users/Jxck","html_url":"https://github.com/Jxck","followers_url":"https://api.github.com/users/Jxck/followers","following_url":"https://api.github.com/users/Jxck/following{/other_user}","gists_url":"https://api.github.com/users/Jxck/gists{/gist_id}","starred_url":"https://api.github.com/users/Jxck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Jxck/subscriptions","organizations_url":"https://api.github.com/users/Jxck/orgs","repos_url":"https://api.github.com/users/Jxck/repos","events_url":"https://api.github.com/users/Jxck/events{/privacy}","received_events_url":"https://api.github.com/users/Jxck/received_events","type":"User","site_admin":false},"created_at":"2015-06-19T01:04:12Z","updated_at":"2015-06-19T01:04:12Z","body":"@annevk, @igrigorik\r\n\r\n > you want the HTML's parser's scanner to find these links\r\n\r\nNo, target URL doesn't always in HTML.\r\nsome application creates URL dynamically from user interaction.\r\nIf url for pre-* are already wrote in HTML at first,\r\nwe can wrote Link tag with that too, and no JS API required.\r\n\r\n\r\n> Perhaps providing some kind of preload dictionary when you install the service worker that you can update in some way?\r\n\r\n> To enable this, we would need a couple of new JS API's that need to be accessible from SW...\r\n\r\n\r\nI think the new API for pre-* should not premise service worker,\r\nthis API should accessible from `window` and `self`(sw), like `fetch()`\r\n\r\nfor example, sw hooks fetching as fetch event, but it's a post processing of fetching happend.\r\nbut in pre-* cases, we need to do them as pre processing (as their name), so there is no event kicks sw. there is no reason to do it only from service worker.\r\n\r\nand more, we can't optimize networks before service worker registering. we can't optimise service worker download itself.\r\n\r\n\r\n\r\n\r\n> rel=preconnect --> navigator.preconnect(origin), or some such.\r\n\r\nlgtm.\r\n\r\n\r\n> rel=preload --> noop, this is simply fetch()\r\n> rel=prefetch --> fetch with low priority (gets back to being able to communicate priority to fetch)\r\n\r\n\r\nresponse of `fetch()` is cached in browser and next clicking A tag will hit the cache ?\r\nor you saying about using Cache API ?\r\n\r\n\r\n> rel=prerender --> perhaps this one needs a separate API as well, since it spawns a new render process and all that. navigator.prerender(url), maybe?\r\n\r\nmaybe."}}