{"action":"created","issue":{"url":"https://api.github.com/repos/whatwg/loader/issues/59","labels_url":"https://api.github.com/repos/whatwg/loader/issues/59/labels{/name}","comments_url":"https://api.github.com/repos/whatwg/loader/issues/59/comments","events_url":"https://api.github.com/repos/whatwg/loader/issues/59/events","html_url":"https://github.com/whatwg/loader/issues/59","id":98590447,"number":59,"title":"Async loading of bundles","user":{"login":"tinganho","id":1324476,"avatar_url":"https://avatars.githubusercontent.com/u/1324476?v=3","gravatar_id":"","url":"https://api.github.com/users/tinganho","html_url":"https://github.com/tinganho","followers_url":"https://api.github.com/users/tinganho/followers","following_url":"https://api.github.com/users/tinganho/following{/other_user}","gists_url":"https://api.github.com/users/tinganho/gists{/gist_id}","starred_url":"https://api.github.com/users/tinganho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tinganho/subscriptions","organizations_url":"https://api.github.com/users/tinganho/orgs","repos_url":"https://api.github.com/users/tinganho/repos","events_url":"https://api.github.com/users/tinganho/events{/privacy}","received_events_url":"https://api.github.com/users/tinganho/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/whatwg/loader/labels/question","name":"question","color":"cc317c"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-08-02T07:13:36Z","updated_at":"2015-08-05T16:25:19Z","closed_at":"2015-08-05T16:18:31Z","body":"Hi, I want to propose async loading of bundles. I don't know if the spec already cover this or if you already have discussed this. Though cannot find similar discussion anywhere. Just some heads up, I'm having some difficulty understanding the current spec. So I use my own code example below.\r\n\r\n#### Problem\r\n\r\nBecause of load time sometimes it is not suitable to bundle everything into one file. One solution is to bundle your application into multiple bundles instead. Another solution is to use http2 with server push. But you can still use server push and bundle at the same time(since you already need to uglify your application code, adding another build step for the bundling won't be that big). Also bundling saves the client from decoding a lot of http2 headers. But also cache-aware server push might need SW support to know which files to be pushed(Here is one discussion in  https://github.com/h2o/h2o/issues/421#issuecomment-126988105), so setting up server push correctly isn't the most trivial task.\r\n\r\n#### Proposal\r\nOne solution to above problems is to let the loader being able to load bundles. Since bundles need at least one root file(not necessarily) to traverse all files and bundle them — we can add a map to the loader, that maps root files to bundle files.\r\n\r\nIn example code(sorry, don't know the whole loader spec and have some difficult to understand it):\r\n```javascript\r\nLoader.bundles({\r\n    '/page1.js': 'page1.bundle.js', \r\n    '/page2.js': 'page2.bundle.js', \r\n})\r\n```\r\n\r\nAll root files defines(not necessarily) an API interface to interact with so we can use the same code for dev and production environment.\r\n\r\n```javascript\r\nif (url === '/page1') {\r\n    var page1  = await Loader.import('/page1.js'); // loads bundle page1.bundle.js instead of page1.js on production\r\n    page1.init();\r\n}\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/whatwg/loader/issues/comments/128058094","html_url":"https://github.com/whatwg/loader/issues/59#issuecomment-128058094","issue_url":"https://api.github.com/repos/whatwg/loader/issues/59","id":128058094,"user":{"login":"matthewp","id":361671,"avatar_url":"https://avatars.githubusercontent.com/u/361671?v=3","gravatar_id":"","url":"https://api.github.com/users/matthewp","html_url":"https://github.com/matthewp","followers_url":"https://api.github.com/users/matthewp/followers","following_url":"https://api.github.com/users/matthewp/following{/other_user}","gists_url":"https://api.github.com/users/matthewp/gists{/gist_id}","starred_url":"https://api.github.com/users/matthewp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthewp/subscriptions","organizations_url":"https://api.github.com/users/matthewp/orgs","repos_url":"https://api.github.com/users/matthewp/repos","events_url":"https://api.github.com/users/matthewp/events{/privacy}","received_events_url":"https://api.github.com/users/matthewp/received_events","type":"User","site_admin":false},"created_at":"2015-08-05T16:25:19Z","updated_at":"2015-08-05T16:25:19Z","body":"@caridy I've noticed you use the term \"folding\" a bit but I'm not familiar with what you mean by that, can you explain?"}}