Why use a packager like WebPack?

-1

I was talking to a friend about the flash and how all code is compiled into a single file and "zapped" on 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 the code?

We worked a bit 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, as opposed to loading "bit by bit "of a traditional web application with imports of JS and CSS.

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

    
asked by anonymous 23.11.2018 / 03:26

1 answer

2

First of all I will tell you that my vision of WebPack and other packers is a bit different from your vision. And that may have other users who will disagree with this bridge of view that I will give you.

Maybe the main benefit of WebPack is the Developer. In fact from my point of view the end user of the WebPack is the very must and not the user who will access the website. I'll explain why.

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

Then I see that the end user is the Dev and not the user that will access the platform. But logically I see advantages to the user of the tb system, because you are going to give it an optimized code, but it could have been optimized at hand, not necessarily with a Webpack of life.

In fact, a lot of what WebPack is good practice is that everyone should do, because they are going to directly impact the system user such as minify code and prefix / em> the properties of the css, or convert images to Base64 or generate sprites , this yes will bring a better experience for the user and a better delivery performance, but this is all good practices and with WebPack easier to do.

    
23.11.2018 / 12:01