4 ms·
You can sort-of already do that with CDNs. Browser still has to parse+run all of that JS though. Because JS-in-browsers is antimodular in that all previous JS
by lomnakkus 12y ago
You can sort-of already do that with CDNs.
Browser still has to parse+run all of that JS though. Because JS-in-browsers is antimodular in that all previous JS on a given page influences all subsequently loaded JS, even if using just script tags with a URL. In a way this is very similar to the pains experienced by the C++ community for many years now.
- amelius 12y agoCould you elaborate on the C++ part?
- lomnakkus 12y agoThe short answer is that "it's complicated". The most accessible long answer I'm aware of for non-C++'ers is at [1] (video). If you prefer text, the standardese version is at [2]. Unfortunately I cannot find a concise text version for laymen except perhaps [3]. [1]: https://www.youtube.com/watch?v=4Xo9iH5VLQ0 https://www.youtube.com/watch?v=4Xo9iH5VLQ0 [2]: http://www.open-std.org/Jtc1/sc22/wg21/docs/papers/2014/n4047.pdf http://www.open-std.org/Jtc1/sc22/wg21/docs/papers/2014/n404... [3]: http://clang.llvm.org/docs/Modules.html http://clang.llvm.org/docs/Modules.html
- DiThi 12y agoC++ doesn't have a "load this module" statement. I does have an "include all the contents of X file here", and file X has to deal with possible duplication and cyclic dependencies, usually with something like #ifndef _SOME_FILE_H #define _SOME_FILE_H // code goes here #endif Also any "module" can define any global variable, so name clashes (esp. with C libraries) are possible. Most languages with proper modules the "global" variables are module-wide. An equally nasty issue happens with JS, where many libraries must be loaded in the proper order and not duplicated. There are a bunch of module systems but none is part of the spec. The good thing is that module systems are easy to make thanks to closures.
- jffry 12y agoFYI you can add an async attribute [1] to a <script> tag to allow it to load and run asynchronously without blocking the rest of the page [1]: http://caniuse.com/#feat=script-async http://caniuse.com/#feat=script-async
- lomnakkus 12y agoGood point. Should've mentioned that. Unfortunately, it's often hard to know if "async" or "defer" will work reliably.