0
votes

i'm trying to optimize my react web app by using gzip compression. I was able to add the webpack plugin and do the compression. But my browser is not using the compressed files it seems. Please help me since I'm new to react. Also note that I use neutrinojs. I'll mention my bundle stats below.

                    Asset       Size  Chunks                                Chunk Names
                   assets/0.3fce4eb2.js   34.2 KiB       0  [emitted] [immutable]         
                assets/0.3fce4eb2.js.br   8.64 KiB          [emitted]                     
                assets/0.3fce4eb2.js.gz    9.6 KiB          [emitted]                     
               assets/0.3fce4eb2.js.map    133 KiB       0  [emitted] [dev]               
                   assets/1.289d6022.js   33.9 KiB       1  [emitted] [immutable]         
                assets/1.289d6022.js.br   8.46 KiB          [emitted]                     
                assets/1.289d6022.js.gz   9.53 KiB          [emitted]                     
               assets/1.289d6022.js.map   98.1 KiB       1  [emitted] [dev]               
                  assets/1.2db4754f.css   99 bytes       1  [emitted] [immutable]         
              assets/1.2db4754f.css.map  238 bytes       1  [emitted] [dev]               
                  assets/10.b8f7f8a6.js   14.6 KiB      10  [emitted] [immutable]         
               assets/10.b8f7f8a6.js.br   5.12 KiB          [emitted]                     
               assets/10.b8f7f8a6.js.gz   5.68 KiB          [emitted]                     
              assets/10.b8f7f8a6.js.map   52.5 KiB      10  [emitted] [dev]               
                  assets/11.14cee74f.js  856 bytes      11  [emitted] [immutable]         
              assets/11.14cee74f.js.map   3.07 KiB      11  [emitted] [dev]               
                 assets/11.74159567.css   7.27 KiB      11  [emitted] [immutable]         
              assets/11.74159567.css.br   1.42 KiB          [emitted]                     
              assets/11.74159567.css.gz   1.66 KiB          [emitted]                     
             assets/11.74159567.css.map   8.37 KiB      11  [emitted] [dev]               
                  assets/12.6d40dbcc.js   1.33 KiB      12  [emitted] [immutable]         
               assets/12.6d40dbcc.js.br  671 bytes          [emitted]                     
               assets/12.6d40dbcc.js.gz  787 bytes          [emitted]                     
              assets/12.6d40dbcc.js.map   1.96 KiB      12  [emitted] [dev]               
                  assets/13.3d0e5b84.js   22.4 KiB      13  [emitted] [immutable]         
               assets/13.3d0e5b84.js.br   5.71 KiB          [emitted]                     
               assets/13.3d0e5b84.js.gz   6.55 KiB          [emitted]                     
              assets/13.3d0e5b84.js.map   87.2 KiB      13  [emitted] [dev]               
                  assets/14.52749a43.js   8.25 KiB      14  [emitted] [immutable]         
               assets/14.52749a43.js.br   2.44 KiB          [emitted]                     
               assets/14.52749a43.js.gz   2.84 KiB          [emitted]                     
              assets/14.52749a43.js.map   19.6 KiB      14  [emitted] [dev]               
                  assets/15.05afd908.js   21.1 KiB      15  [emitted] [immutable]         
               assets/15.05afd908.js.br   7.48 KiB          [emitted]                     
               assets/15.05afd908.js.gz   9.68 KiB          [emitted]                     
              assets/15.05afd908.js.map    154 KiB      15  [emitted] [dev]               
                   assets/2.25cbca89.js  252 bytes       2  [emitted] [immutable]         
               assets/2.25cbca89.js.map  547 bytes       2  [emitted] [dev]               
                  assets/3.36420eb7.css  618 bytes       3  [emitted] [immutable]         
              assets/3.36420eb7.css.map  938 bytes       3  [emitted] [dev]               
                   assets/3.6d75eeb4.js   22.2 KiB       3  [emitted] [immutable]         
                assets/3.6d75eeb4.js.br   6.07 KiB          [emitted]                     
                assets/3.6d75eeb4.js.gz   6.91 KiB          [emitted]                     
               assets/3.6d75eeb4.js.map   62.9 KiB       3  [emitted] [dev]               
                   assets/4.aa3c9f8e.js   81.1 KiB       4  [emitted] [immutable]         
                assets/4.aa3c9f8e.js.br   16.2 KiB          [emitted]                     
                assets/4.aa3c9f8e.js.gz   18.5 KiB          [emitted]                     
               assets/4.aa3c9f8e.js.map    265 KiB       4  [emitted] [dev]               
                  assets/4.de23ee90.css   90 bytes       4  [emitted] [immutable]         
              assets/4.de23ee90.css.map  259 bytes       4  [emitted] [dev]               
                   assets/7.0b2209a3.js   4.22 MiB       7  [emitted] [immutable]  [big]  
                assets/7.0b2209a3.js.br    940 KiB          [emitted]              [big]  
                assets/7.0b2209a3.js.gz   1.19 MiB          [emitted]              [big]  
               assets/7.0b2209a3.js.map   14.6 MiB       7  [emitted] [dev]               
                  assets/7.59caa759.css    259 KiB       7  [emitted] [immutable]  [big]  
               assets/7.59caa759.css.br   23.6 KiB          [emitted]                     
               assets/7.59caa759.css.gz   30.6 KiB          [emitted]                     
              assets/7.59caa759.css.map    314 KiB       7  [emitted] [dev]            

I really don't know why there are this much of files because I have seen only 2 to 4 files in examples. But I can see that there are gzip and brotli compressed files. But the browser says there are no content-encoding. I only added the plugin to config file and I think there is something more to do. Also I'm running this locally. Please help me with what could have gone wrong. Thank you.

chrome says no content-encoding

1

1 Answers

0
votes

If you have express js backend you can do something like below with compression package.in your main js file.

const compression = require('compression')

app.use(compression())

compression package