可搜索,可注册,可登录,致敬逗比大佬!尽在救援版逗比根据地 dbgjd.com
投稿文章 | 广告合作 | Telegram 群组 / 公告频道 / 使用教程

Introducing a simple WebP Server

News ssj2_da1m0z1995 165℃ 0评论

In the previous article I’ve introduced Nginx + mod_pagespeed, which is a great tool that allows us to convert JPGs and PNGs to WebP on the fly, the converted files can be delivered by rewriting the related HTML Code.

Given the scenario I host all my images on a dedicated server (https://blog-assets.nova.moe) with Nginx for static files server, mod_pagespeed cannot perform the on-the-fly conversion at this time.

So I’ve decided to create a simple server that can convert all JPG/PNG files to WebP format without changing the URLs.

Means you can still access images with /xxx.jpg but the image is in WebP format and the file size of it is smaller.

With some self-learning, there is a prototype available on GitHub: n0vad3v/webp_server written with Node, ExpressJS and cwebp, and the effect of it is quite fascinating, as below.

Requests before and after WebP server

On a typical post with a lot of images such as 《那些年我开过的车(们)》, the images are always large.

Introducing a simple WebP Server

With the WebP Server, the requests are becoming much more friendly (Look at eado.pov, it’s original size is 1.4M and the WebP image size is only 476K, wow!).

Introducing a simple WebP Server

PageSpeed Insights

The image sizes are a big minus on score, so we just focus on the relative of those.

Before WebP Server:

Introducing a simple WebP Server

After WebP Server:

Introducing a simple WebP Server

转载请注明:逗比根据地 » Introducing a simple WebP Server

喜欢 (0)
发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址