How do I use Zlib.js, a library that can be Gzip compressed in JavaScript?

Asked 1 years ago, Updated 1 years ago, 26 views

https://pisuke-code.com/javascript-usage-of-zlib-js/

The above is the detailed article, but as a beginner, I couldn't understand it well, so I would appreciate it if you could give me an easy explanation.

I use Yahoo! shopping store and use triple function to create a shop with html from scratch.When I tried to set up Gzip compression and cache using .htaccess to increase the display speed of the shop page, I found that .htaccess was not available.

So I looked it up and found out that there is a way to compress Gzip with JavaScript.

However, although it is duplicated, I am at a loss for knowledge.

I would like to use JavaScript to Gzip the three html/css/js.

What source code should I include?

Thank you for your cooperation.

javascript

2022-09-30 19:32

2 Answers

If it's too late for visitors to view the shop page, what needs to be improved is the time it takes to transfer data to the server → the viewer.If the data transfer rate is slow (the line is thin), gzip compression on the server side can reduce the amount of data transfer (instead, the server CPU load increases).As a way to do this

    Enable mod_deflate in
  • httpd.conf
  • Enable zlib.output_compression=on in
  • php.ini (when using

    Either way, you must have permission to manipulate the configuration file httpd.conf or .htaccess.If you don't have any, you can't touch it.Also, if it's a well-known site, you may have already set up the above settings, so you should check it out.

    The slow cause is not necessarily the thickness of the line, so there is no point in taking any random measures.You should investigate where the delay is before you start.

    The introductory article is designed to compress data before uploading on the viewer's side to reduce data transfer time in the opposite direction, viewer → server direction.Therefore, referring to the introduction article does not shorten the transfer time for the server→viewer.It doesn't fit your purpose.


    2022-09-30 19:32

The purpose is the means.If you want to "increase page speed", you need to identify slow spots and improve those areas.
Zlib.js does not increase page speed.

When I used Google's speed measuring site, I was told to compress html/css/javascript with gzip. (omitted) Does this not increase the speed?

It won't go up.You should understand Pareto's law.If you use Zlib.js to reduce the time required for that part to the limit and 0, the page speed itself will not increase if the percentage of the total page speed is small.
For example, if you need 20 seconds to prepare data, 1 second to communicate, and 3 seconds to draw (the numbers are random), Zlib.js will make communication more efficient, but overall, 24 seconds → 23 seconds.

So, as I pointed out in the beginning, we need to identify the slow spots.


2022-09-30 19:32

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.