this post was submitted on 22 Sep 2023
25 points (93.1% liked)

Programming

16975 readers
1288 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities [email protected]



founded 1 year ago
MODERATORS
 

I mean, sure, that's probably heavily influenced by the need for bundling for the frontend.

But it isn't done blindly. Bundlers reduce the overall size of the code, either due to minification or tree-shaking (removing unused modules). It also removes the filesystem overhead of resolving and opening other modules.

Would bundling be useful in other interpreted languages?

I suppose you may count JVM's compilation to bytecode as being very similar.

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 0 points 11 months ago* (last edited 11 months ago)
  1. it can increase execution speed because the alternative is usually hosting a file separately and making a separate http request to get that file. Bundling allows you to deliver one bigger file instead of multiple small files, saving on network requests.

  2. tree-shaking, minifcation, g-zipping - to get the best performance you want all of your code and only your code. also gzip(filepart1 + filepart2) < gzip(filepart1) + gzip(filepart2) + ...

But I think the biggest factor is

  1. In JS it's very common that you don't have control over where your code is built or executed. With bundling you can usually specify a build target so you can write your code in modern JS with the guarantee that the output will be usable on older systems.

Most of the time if your code doesn't work because of an old environment the end user will just update their environment but with most JS being written for the web it was beneficial if not required that you put in the effort to make your code run on older environments because your target user base might not have the permissions or technical abilities to upgrade the "environment" (aka browser).