4 ms·
It would be kind of nice if you could import modules directly from HTTP sources, like Go. For example: import _ from package 'github.com/lodash/lodash/tree
by tomphoolery 11y ago
It would be kind of nice if you could import modules directly from HTTP sources, like Go. For example:
import _ from package 'github.com/lodash/lodash/tree/4.8.2';
import $ from package 'jquery.com/version/2.2.0';
Your browser would make the OOB requests and cache the results in a shared directory, which any JS code that's running locally can use. This way, HTTP requests for 3rd-party components shared across websites aren't repeated over and over again for the same libraries. And it could even be extended to CSS:
@import package("github.com/twbs/bootstrap/tree/3.3.6");
- lisivka 11y agoSuch style of dependency declaration creates unnecessary dependencies on remote sites, which are hard to fix when dependency is broken.
- true_religion 11y agoThat's essentially what people are doing already with script tags, except they're not declaring their dependencies anywhere.
- et1337 11y agoBetter idea would be to reference it via cryptographic signature. Then you could host your own copy of lodash for example, but still benefit if a client already has it downloaded from a different site.
- moreati 11y agoSubresource Integrity is the standard for that https://www.w3.org/TR/SRI/ https://www.w3.org/TR/SRI/
- et1337 11y agoDo you know if this allows consolidation of multiple copies of the same resource from different hosts?
- moreati 11y agoI don't know. At a guess such optimization would be beyond the scope of the standard - hence up to each vendor/browser/user-agent.
- woogley 11y agoNot currently, because it conflicts with CSP. See https://news.ycombinator.com/item?id=10311020 https://news.ycombinator.com/item?id=10311020
- deleted 11y ago[deleted]