Why use a packer like Webpack?

Asked

Viewed 365 times

-1

I was talking to a friend about the flash and how all the code is compiled in a single file and "zuamos" about the "1tera" that the user has to download, of course, exaggerating...

But then a question arose: What is the advantage of using Webpack, for example, to package code?

We work a little with Angular 5/6 and all the code (including HTML and CSS) is packaged in 3 files, which may cause some inconvenience for users with a slower internet, in exchange for loading "little by little" a traditional web application with Imports of JS and CSS.

If the best frameworks frontend use, should be worth, but what is the gain in performance when packaging the code?

  • 2

    Maybe the question has a canonical answer, but I need to comment/request some things. If there is a great concern about the performance of the application for users with slow internet, it may be the case to review the use of Angular. Frameworks generally solve some specific problems by adding a generally unnecessary load to the project. Another thing is that you start from the premise that should be worth it because the "best frameworks" use it; what is your criterion for choosing the "best frameworks"? What would those be?

  • By better I meant the most famous, maybe they are not the best or are the best in a certain subject but this is what I meant, as angular, Vue and React, for example.

  • When you talk about "users with a slower internet" they will be negatively affected by a single request to a "super Bundle" is going against what the webpack itself preaches. If your application is too complex, it will obviously perform numerous HTTP requests, and this can cause a problem for those who do not enjoy a quality connection, you can understand this on their website here https://webpack.js.org/concepts/why-webpack/.

1 answer

2

First let me tell you that my view of Webpack and other packers is a little different from your view. And there may be other users who will disagree with this bridge that I’m giving you.

Perhaps the main beneficiary of Webpack is the Developer. Actually in my point of view the end user of Webpack is the very should and not the user who will access the site. I explain why.

I believe that the main advantage of packers is to do a part of the work of developers and automate various routines... I justify myself with these examples. Webpack will prefix all your CSS styles for you have no problem of crossbrowser. He will compile his SASS, SCSS, LESS or Stylus on a standard style sheet .CSS that the browser will be able to read. It will do the includes of everything you want in the document, it will use something like the Babel for example to handle the compatibility of your Java Script for old browsers. It goes minify your code, remove comments etc...

So I see that the end user is Dev. and not the user who will access the platform. But logically I see advantages for the user of the system tb, because vc will deliver to him an optimized code, but that could have been optimized at hand, not necessarily with a Webpack of life.

Until pq, in fact much of what the Webpack are good practices that everyone should do, because they are the ones that will directly impact the system user as minify the code and prefix css properties, or convert images to Base64 or generate sprites, this will bring a better user experience and a better delivery performance, but this is all good practice and with Webpack it is easier to do.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.