4 ms·
modern browsers support the import syntax natively, so it really shouldn't be a lot of overhead to import it.
by 0xCMP 2y ago
modern browsers support the import syntax natively, so it really shouldn't be a lot of overhead to import it.
- notpushkin 2y agoThe overhead here would be the need to make another request just for these two functions. On the other hand, with bundling though it’s totally fine to have a module just for these two helpers. (Even better if it can be inlined, but I haven’t seen anything supporting this since Prepack, which is still POC I think.)
- mg 2y agoAFAIK modern HTTP versions like HTTP/3 can request multiple files in a single network packet. So it is basically free to do "another request". As the data request goes out and the data comes in in packets with other "requests".
- theandrewbailey 2y agoA network request isn't free, only less costly than it used to be. Even with HTTP 3, your JS execution is stalled for however long the RTT is back to the server. That could be 500+ ms if its on the side of the world and doesn't have a CDN.
- mg 2y agoDepends on the import tree. The way I understand it, this: import { x } from '/a.js'; import { y } from '/b.js'; Does not take longer than this: import { x } from '/a.js'; Because the message to the server "Give me b.js" goes out in the same network packet as "Give me a.js" and the data of b.js comes back in the same packet(s) as the data of a.js.