diff --git a/Dockerfile.builder b/Dockerfile.builder index 596fe40..28ef43d 100644 --- a/Dockerfile.builder +++ b/Dockerfile.builder @@ -10,7 +10,7 @@ RUN echo 'APT::Acquire::Retries "3";' >/etc/apt/apt.conf.d/80-retries && \ golang \ jq npm -RUN git clone --single-branch --branch v4.0.3 --depth=1 https://github.com/mozilla/mozjpeg.git && \ +RUN git clone --single-branch --branch v4.0.3 --depth 1 https://github.com/mozilla/mozjpeg.git && \ cd mozjpeg && \ mkdir build && \ cd build && \ @@ -32,7 +32,7 @@ RUN git clone --depth 1 https://github.com/AOMediaCodec/libavif.git && \ cd /usr/local/bin && \ ln -s /libavif/build/avifenc -RUN npm install -g svgo uglify-js +RUN npm install -g svgo uglify-js html-minifier COPY cmd/alt_path /cmd/alt_path RUN (cd /cmd/alt_path && go get && go build -o /usr/local/bin/alt_path) diff --git a/README.md b/README.md index 1c6234b..c1b32d9 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,8 @@ Currently the following optimizations are performed: - WebP image files with a single frame: variants are created in AVIF, PNG and JPEG (the last one only when the image contains no transparent pixels) - SVG image files are minified using svgo - and are then compressed as other files (see below) - JSON files are minified using jq - and are then compressed as other files (see below) -- JS files are minified using UglifyJS - and are then compressed as other files (see below) +- JS files are minified using [UglifyJS](https://github.com/mishoo/UglifyJS) - and are then compressed as other files (see below) +- HTML files are minified using [htmlminifier](https://github.com/kangax/html-minifier) - and are then compressed as other files (see below) - Other files are statically compressed with zopfli (gzip), brotli and zstandard (zstd) ## Asset server @@ -58,7 +59,7 @@ When testing the live demo, you can check in the developer console the negotiati
SourceOptimized variantsLive demo
a-chance-of-northern-lights.jpg (1479380 bytes) -a-chance-of-northern-lights.jpg (305538 bytes)
+a-chance-of-northern-lights.jpg (305494 bytes)
a-chance-of-northern-lights.jpg.webp (266378 bytes)
a-chance-of-northern-lights.jpg
bear.webp (132108 bytes) @@ -88,7 +89,7 @@ When testing the live demo, you can check in the developer console the negotiati kiss.gif.webp (197796 bytes)
kiss.gif
make-it-new.jpg (1084975 bytes) -make-it-new.jpg (369470 bytes)
+make-it-new.jpg (369427 bytes)
make-it-new.jpg.avif (357416 bytes)
make-it-new.jpg.webp (338696 bytes)
make-it-new.jpg @@ -104,10 +105,10 @@ When testing the live demo, you can check in the developer console the negotiati pattern-color.png.webp (162706 bytes)
pattern-color.png
reddit.html (982765 bytes) -reddit.html (982765 bytes)
-reddit.html.br (180965 bytes)
-reddit.html.gz (291533 bytes)
-reddit.html.zst (192423 bytes)
+reddit.html (940603 bytes)
+reddit.html.br (179555 bytes)
+reddit.html.gz (289633 bytes)
+reddit.html.zst (191232 bytes)
reddit.html
rose.webp (81978 bytes) rose.webp (81978 bytes)
@@ -130,10 +131,10 @@ When testing the live demo, you can check in the developer console the negotiati terminated.gif.webp (34418 bytes)
terminated.gif
wikipedia.html (81182 bytes) -wikipedia.html (81182 bytes)
-wikipedia.html.br (15326 bytes)
-wikipedia.html.gz (18541 bytes)
-wikipedia.html.zst (18084 bytes)
+wikipedia.html (75187 bytes)
+wikipedia.html.br (14662 bytes)
+wikipedia.html.gz (17615 bytes)
+wikipedia.html.zst (17249 bytes)
wikipedia.html
@@ -152,7 +153,6 @@ PRs are welcome. Some ideas for what to add: - Add JPEG-XL `jxl` content-encoding variant - Add WebP2 variants for image assets - Other data formats - - Add HTML minification - Add CSS minification - Dictionary compression - Add zstd/gzip/brotli dictionary generation diff --git a/assets/optimized/a-chance-of-northern-lights.jpg b/assets/optimized/a-chance-of-northern-lights.jpg index 25af6af..72b3795 100644 Binary files a/assets/optimized/a-chance-of-northern-lights.jpg and b/assets/optimized/a-chance-of-northern-lights.jpg differ diff --git a/assets/optimized/make-it-new.jpg b/assets/optimized/make-it-new.jpg index 91660f0..f9490f8 100644 Binary files a/assets/optimized/make-it-new.jpg and b/assets/optimized/make-it-new.jpg differ diff --git a/assets/optimized/reddit.html b/assets/optimized/reddit.html index 31c4d46..141952d 100644 --- a/assets/optimized/reddit.html +++ b/assets/optimized/reddit.html @@ -1,2043 +1 @@ - - - - - - - - - - - - - - - - reddit: the front page of the internet - - - - -
-
Press J to jump to the feed. Press question mark to learn the rest of the keyboard shortcuts
Trending today
Popular posts
Hot
NewTop
48.8k
Subreddit Icon
Posted by19 hours ago
Helpful61Wholesome63Silver73Heartwarming
- -
48.8k
Vote
promotedPosted by1 year ago
Comments are locked
- -
Vote
0 comments
69.9k
69.9k
6.7k comments
407
Subreddit Icon
Posted by8 hours ago
HelpfulSilver
spoiler
- -
407
366 comments

Top broadcast

114
Subreddit Icon
Posted by9 hours ago
spoiler
- -
114
162 comments
82.6k
Subreddit Icon
Posted by12 hours ago
Explodey HeartMade Me SmileGoldBravo!
- -
82.6k
1.2k comments
27
27
15 comments
Reddit Premium
The best Reddit experience, with monthly Coins

Trending Communities

r/FrancePics

9,502 members

r/buecher

4,884 members

r/germany

263,847 members

r/Geschichte

2,763 members

r/casualEurope

12,527 members

Popular Communities
Gaming
Sports
TV
Travel
Health & Fitness
Fashion
-
- - - - \ No newline at end of file +reddit: the front page of the internet
Press J to jump to the feed. Press question mark to learn the rest of the keyboard shortcuts
Trending today
Popular posts
Hot
NewTop
48.8k
Subreddit Icon
Posted by19 hours ago
Helpful61Wholesome63Silver73Heartwarming
48.8k
Vote
promotedPosted by1 year ago
Comments are locked
Vote
0 comments
69.9k
69.9k
6.7k comments
407
Subreddit Icon
Posted by8 hours ago
HelpfulSilver
spoiler
407
366 comments

Top broadcast

114
Subreddit Icon
Posted by9 hours ago
spoiler
114
162 comments
82.6k
Subreddit Icon
Posted by12 hours ago
Explodey HeartMade Me SmileGoldBravo!
82.6k
1.2k comments
27
27
15 comments
Reddit Premium
The best Reddit experience, with monthly Coins

Trending Communities

r/FrancePics

9,502 members

r/buecher

4,884 members

r/germany

263,847 members

r/Geschichte

2,763 members

r/casualEurope

12,527 members

Popular Communities
Gaming
Sports
TV
Travel
Health & Fitness
Fashion
\ No newline at end of file diff --git a/assets/optimized/reddit.html.br b/assets/optimized/reddit.html.br index 5840b46..082668a 100644 Binary files a/assets/optimized/reddit.html.br and b/assets/optimized/reddit.html.br differ diff --git a/assets/optimized/reddit.html.gz b/assets/optimized/reddit.html.gz index 2b8b810..6bf6e3a 100644 Binary files a/assets/optimized/reddit.html.gz and b/assets/optimized/reddit.html.gz differ diff --git a/assets/optimized/reddit.html.zst b/assets/optimized/reddit.html.zst index 4c1172b..3a244f3 100644 Binary files a/assets/optimized/reddit.html.zst and b/assets/optimized/reddit.html.zst differ diff --git a/assets/optimized/wikipedia.html b/assets/optimized/wikipedia.html index 8d295ad..8a4d1d0 100644 --- a/assets/optimized/wikipedia.html +++ b/assets/optimized/wikipedia.html @@ -1,576 +1 @@ - - - - -Wikipedia, the free encyclopedia - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
- -
-
-
-

Main Page

-
-
From Wikipedia, the free encyclopedia
-
-
- -
- Jump to navigation - Jump to search -
- - - - - - -
-
-

Today's featured picture

-
- - - -
Tule elk - -

The tule elk (Cervus canadensis nannodes) is a subspecies of elk found only in California, seen here at Tomales Point in Point Reyes National Seashore. When Europeans arrived in the area, an estimated 500,000 tule elk roamed these regions, but the animals were thought to have been hunted to extinction by 1870. A single pair was discovered on the ranch of the cattle baron Henry Miller in 1874. He ordered his men to protect them, and is credited with the survival of the subspecies. As of 2019, the total Californian population is estimated to be 5,700. -

-

Photograph credit: Frank Schulenburg

- - -
-
-
-
-

Other areas of Wikipedia

-
-
  • Community portal – Bulletin board, projects, resources and activities covering a wide range of Wikipedia areas.
  • -
  • Help desk – Ask questions about using Wikipedia.
  • -
  • Local embassy – For Wikipedia-related communication in languages other than English.
  • -
  • Reference desk – Serving as virtual librarians, Wikipedia volunteers tackle your questions on a wide range of subjects.
  • -
  • Site news – Announcements, updates, articles and press releases on Wikipedia and the Wikimedia Foundation.
  • -
  • Village pump – For discussions about Wikipedia itself, including areas for technical issues and policies.
-
-

Wikipedia's sister projects

-
-

Wikipedia is hosted by the Wikimedia Foundation, a non-profit organization that also hosts a range of other projects: -

-
- -
-

Wikipedia languages

-
-
-
- - - - -
-
- -
-
-
-
-
- -
-

Navigation menu

-
- - - -
- - - - - - -
-
- - - - - - - - -
-
- -
- - - - - - - - - - - - - - - - -
- -
- - - - - - - \ No newline at end of file +Wikipedia, the free encyclopedia

Main Page

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

Today's featured picture

Tule elk

The tule elk (Cervus canadensis nannodes) is a subspecies of elk found only in California, seen here at Tomales Point in Point Reyes National Seashore. When Europeans arrived in the area, an estimated 500,000 tule elk roamed these regions, but the animals were thought to have been hunted to extinction by 1870. A single pair was discovered on the ranch of the cattle baron Henry Miller in 1874. He ordered his men to protect them, and is credited with the survival of the subspecies. As of 2019, the total Californian population is estimated to be 5,700.

Photograph credit: Frank Schulenburg

Other areas of Wikipedia

  • Community portal – Bulletin board, projects, resources and activities covering a wide range of Wikipedia areas.
  • Help desk – Ask questions about using Wikipedia.
  • Local embassy – For Wikipedia-related communication in languages other than English.
  • Reference desk – Serving as virtual librarians, Wikipedia volunteers tackle your questions on a wide range of subjects.
  • Site news – Announcements, updates, articles and press releases on Wikipedia and the Wikimedia Foundation.
  • Village pump – For discussions about Wikipedia itself, including areas for technical issues and policies.

Wikipedia's sister projects

Wikipedia is hosted by the Wikimedia Foundation, a non-profit organization that also hosts a range of other projects:

Wikipedia languages

Navigation menu

\ No newline at end of file diff --git a/assets/optimized/wikipedia.html.br b/assets/optimized/wikipedia.html.br index de124c0..226c159 100644 Binary files a/assets/optimized/wikipedia.html.br and b/assets/optimized/wikipedia.html.br differ diff --git a/assets/optimized/wikipedia.html.gz b/assets/optimized/wikipedia.html.gz index 56fbe8a..ad63a98 100644 Binary files a/assets/optimized/wikipedia.html.gz and b/assets/optimized/wikipedia.html.gz differ diff --git a/assets/optimized/wikipedia.html.zst b/assets/optimized/wikipedia.html.zst index b5f763f..966e6d4 100644 Binary files a/assets/optimized/wikipedia.html.zst and b/assets/optimized/wikipedia.html.zst differ diff --git a/compress.sh b/compress.sh index 394052e..fe5406f 100755 --- a/compress.sh +++ b/compress.sh @@ -164,6 +164,13 @@ JS_FILES=$( -printf '%P\n' \ ) +HTML_FILES=$( + find . -type f \ + \( -iname '*.htm' -or -iname '*.html' \) \ + -size +1 \ + -printf '%P\n' \ +) + COMPRESSIBLE_FILES=$( find . -type f \ -not -iname '*.gif' \ @@ -308,6 +315,15 @@ minify_js() { FILE=$1 foreach "$JS_FILES" minify_js +## minify html files + +minify_html() { FILE=$1 + html-minifier --collapse-whitespace --remove-comments --remove-optional-tags --remove-redundant-attributes --remove-script-type-attributes --remove-tag-whitespace --use-short-doctype --minify-css true --minify-js true -o "$FILE.htmlminifier" -- "$FILE" || rm -f "$FILE.htmlminifier" + mv -f "$FILE.htmlminifier" "$FILE" +} + +foreach "$HTML_FILES" minify_html + ## precompress uncompressed files wait # some files that we need to compress may still be being worked on