Slide 1

Slide 1 text

SMALLER IS ALWAYS BETTER

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

PHIL NASH @philnash https:/ /philna.sh [email protected]

Slide 5

Slide 5 text

@philnash

Slide 6

Slide 6 text

@philnash

Slide 7

Slide 7 text

@philnash

Slide 8

Slide 8 text

@philnash

Slide 9

Slide 9 text

GZIP

Slide 10

Slide 10 text

Accept-Encoding: gzip @philnash

Slide 11

Slide 11 text

NGINX server { gzip on; gzip_disable "msie6"; gzip_vary on; } 01. 02. 03. 04. 05. @philnash

Slide 12

Slide 12 text

@philnash

Slide 13

Slide 13 text

NEW GEM TIME @philnash

Slide 14

Slide 14 text

JEKYLL-GZIP Jekyll::Hooks.register :site, :post_write do |site| if ENV["JEKYLL_ENV"] == "production" Jekyll::Gzip::Compressor.new(site).compress end end 01. 02. 03. 04. 05. @philnash

Slide 15

Slide 15 text

JEKYLL-GZIP def compress site.each_site_file do |file| compress_file(file.destination(site.dest)) end end 01. 02. 03. 04. 05. @philnash

Slide 16

Slide 16 text

JEKYLL-GZIP def compress_file(file_name) zipped = "#{file_name}.gz" Zlib::GzipWriter.open(zipped, Zlib::BEST_COMPRESSION) do |gz| gz.mtime = File.mtime(file_name) gz.orig_name = file_name gz.write IO.binread(file_name) end end 01. 02. 03. 04. 05. 06. 07. 08. @philnash

Slide 17

Slide 17 text

JEKYLL-GZIP def compress_file(file_name) zipped = "#{file_name}.gz" Zlib::GzipWriter.open(zipped, Zlib::BEST_COMPRESSION) do |gz| gz.mtime = File.mtime(file_name) gz.orig_name = file_name gz.write IO.binread(file_name) end end 01. 02. 03. 04. 05. 06. 07. 08. @philnash

Slide 18

Slide 18 text

TABLE OF COMPRESSION Results when compressing unmini ed jQuery style bytes % uncompressed 271,751 - gzip default 80,669 -70.32% gzip best 80,268 -70.46% @philnash

Slide 19

Slide 19 text

SMALLER IS ALWAYS BETTER

Slide 20

Slide 20 text

@philnash

Slide 21

Slide 21 text

ZOPFLI

Slide 22

Slide 22 text

Accept-Encoding: gzip @philnash

Slide 23

Slide 23 text

NEW GEM TIME @philnash

Slide 24

Slide 24 text

JEKYLL-ZOPFLI require "zopfli" def compress_file(file_name) zipped = "#{file_name}.gz" contents = Zopfli.deflate(File.read(file_name), format: :gzip) File.open(zipped, "w+") do |file| file << contents end end 01. 02. 03. 04. 05. 06. 07. 08. @philnash

Slide 25

Slide 25 text

TABLE OF COMPRESSION Results when compressing unmini ed jQuery style bytes % uncompressed 271,751 - gzip default 80,669 -70.32% gzip best 80,268 -70.46% zop i 76,352 -71.90% @philnash

Slide 26

Slide 26 text

SMALLER IS ALWAYS BETTER

Slide 27

Slide 27 text

NGINX server { gzip off; gzip_static on; gzip_disable "msie6"; gzip_vary on; } 01. 02. 03. 04. 05. 06. @philnash

Slide 28

Slide 28 text

@philnash

Slide 29

Slide 29 text

BROTLI

Slide 30

Slide 30 text

Accept-Encoding: br @philnash

Slide 31

Slide 31 text

@philnash

Slide 32

Slide 32 text

HTTPS @philnash

Slide 33

Slide 33 text

NEW GEM TIME @philnash

Slide 34

Slide 34 text

JEKYLL-BROTLI require 'brotli' def compress_file(file_name) compressed = "#{file_name}.br" contents = Brotli.deflate(File.read(file_name), quality: 11) File.open(compressed, "w+") do |file| file << contents end end 01. 02. 03. 04. 05. 06. 07. 08. @philnash

Slide 35

Slide 35 text

TABLE OF COMPRESSION Results when compressing unmini ed jQuery style bytes % uncompressed 271,751 - gzip default 80,669 -70.32% gzip best 80,268 -70.46% zop i 76,352 -71.90% brotli quality 6 75,302 -72.29% @philnash

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

JEKYLL-BROTLI require 'brotli' def compress_file(file_name) compressed = "#{file_name}.br" contents = Brotli.deflate(File.read(file_name), quality: 11) File.open(compressed, "w+") do |file| file << contents end end 01. 02. 03. 04. 05. 06. 07. 08. @philnash

Slide 38

Slide 38 text

TABLE OF COMPRESSION Results when compressing unmini ed jQuery style bytes % uncompressed 271,751 - gzip default 80,669 -70.32% gzip best 80,268 -70.46% zop i 76,352 -71.90% brotli quality 6 75,302 -72.29% brotli quality 11 66,920 -75.37% @philnash

Slide 39

Slide 39 text

RESULTS @philnash

Slide 40

Slide 40 text

A FIGHT @philnash

Slide 41

Slide 41 text

@philnash

Slide 42

Slide 42 text

“A FIGHT” @philnash

Slide 43

Slide 43 text

TAKEAWAYS @philnash

Slide 44

Slide 44 text

JEKYLL https:/ /github.com/philnash/jekyll-gzip https:/ /github.com/philnash/jekyll-zop i https:/ /github.com/philnash/jekyll-brotli @philnash

Slide 45

Slide 45 text

RAILS https:/ /github.com/miyucy/zop i Rails.application.assets.gzip = :zopfli https:/ /github.com/hansottowirtz/sprockets- exporters_pack @philnash

Slide 46

Slide 46 text

@philnash

Slide 47

Slide 47 text

SMALLER IS ALWAYS BETTER

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

THANKS! @philnash https:/ /philna.sh [email protected]