Choose a version:
47% The original file has 471591 bytes (460.5k) and is available from the project website.
There you can find the official minified version, too, which brings down the size to 221471 bytes (216.3k, 47%).

After GZIP compression these minified files vary in size:
Boot
  84697 bytes (82.7k)
CDN
cdnjs
  74452 bytes (72.7k)
CDN
gzip -6 (default)
  73772 bytes (72.0k)
local copy
gzip -9
  73518 bytes (71.8k)
local copy
libdeflate -12
  70701 bytes (69.0k)
local copy
7zip -mx=9 -tgzip
  70253 bytes (68.6k)
local copy
pigz -11 -n
  69844 bytes (68.2k)
local copy
kzip -s0 -rn -b7
  69823 bytes (68.2k)
local copy
Zopfli
  69732 bytes (68.1k)
local copy
Zopfli (defluff)
  69731 bytes (68.1k)
local copy

perma-link to the smallest file on my server:
http://minime.stephan-brumme.com/files/d3/d3-4.12.1.min.js

You will automatically get the smallest D3 4.12.1 file, ETag caching is available and
if your browser doesn't support GZIP decompression then the uncompressed version will be sent.

Currently best Zopfli settings

Save 4720 bytes by using my D3 4.12.1 Zopfli version instead of the best available CDN (6.77% smaller than cdnjs, 69732 vs. 74452 bytes):
You can use my super-compressed files for whatever purpose you like as long as you respect the library's original license agreement.
There are no restrictions from my side - but please avoid hot-linking if you run a high-traffic website.

These command-line settings yielded the best compression ratio so far (Linux version of zopfli-krzymod):
zopfli --i1000000 --mb8 --mls8192 --bsr18 --lazy --ohh

(found December 29, 2017)
Description Value Parameter
iterations 1000000  --i1000000
maximum blocks 8  --mb8
maximum length score 8192  --mls8192
block splitting recursion 18  --bsr18
lazy matching in LZ77 yes  --lazy
optimized Huffman headers yes  --ohh
initial random W for iterations 1  --rw1
initial random Z for iterations 2  --rz2

Even Smaller Files Thanks To Defluff

Zopfli's output can be further optimized by the defluff tool.
In this particular case, defluff saves 1 more byte (69731 bytes).

Verify file integrity

After decompression, my uncompressed files are identical to the original ones:

MD5:
curl --silent --compressed https://raw.githubusercontent.com/mbostock/d3/v4.12.1/d3.zip --location | md5sum
002b174a7e3f3d53a59bf0a382b01d61  -
curl --silent --compressed http://minime.stephan-brumme.com/files/d3/d3-4.12.1.min.zopfli.js.gz | md5sum
002b174a7e3f3d53a59bf0a382b01d61  -

SHA1:
curl --silent --compressed https://raw.githubusercontent.com/mbostock/d3/v4.12.1/d3.zip --location | sha1sum
5dbcb61a747b0ad688c79b845adaf466d4cc6e84  -
curl --silent --compressed http://minime.stephan-brumme.com/files/d3/d3-4.12.1.min.zopfli.js.gz | sha1sum
5dbcb61a747b0ad688c79b845adaf466d4cc6e84  -

All listed CDNs deliver identical contents:
CDN Size (compressed) MD5 (uncompressed) Timestamp
Boot 84697 bytes 002b174a7e3f3d53a59bf0a382b01d61 January 1, 2018 @ 13:46
cdnjs 74452 bytes 002b174a7e3f3d53a59bf0a382b01d61 December 26, 2017 @ 21:32

Note: only the MD5 hashes are shown to keep things simple.

Other Versions

Available D3 versions at minime.stephan-brumme.com:

5.1.0, 5.0.1, 5.0.0,
4.13.0, 4.12.2, 4.12.1, 4.12.0, 4.11.0, 4.10.2, 4.10.1, 4.10.0,
4.9.1, 4.9.0, 4.8.0, 4.7.4, 4.7.3, 4.7.2, 4.7.1, 4.7.0, 4.6.0, 4.5.0, 4.4.4, 4.4.3, 4.4.2, 4.4.1, 4.4.0, 4.3.0, 4.2.8, 4.2.7, 4.2.6, 4.2.5, 4.2.4, 4.2.3, 4.2.2, 4.2.1, 4.2.0, 4.1.1, 4.1.0, 4.0.0,
3.5.17, 3.5.16, 3.5.15, 3.5.14, 3.5.13, 3.5.12, 3.5.11, 3.5.10, 3.5.9, 3.5.8, 3.5.7, 3.5.6, 3.5.5, 3.5.4, 3.5.3, 3.5.2, 3.5.1, 3.5.0, 3.4.13, 3.4.12, 3.4.11, 3.4.10, 3.4.9, 3.4.8, 3.4.6, 3.4.5, 3.4.4, 3.4.3, 3.4.2, 3.4.1, 3.4.0, 3.3.13, 3.3.12, 3.3.11, 3.3.10, 3.3.9, 3.3.8, 3.3.7, 3.3.6, 3.3.5, 3.3.4, 3.3.3, 3.3.2, 3.3.1, 3.3.0, 3.2.8, 3.2.7, 3.2.6, 3.2.5, 3.2.4, 3.2.3, 3.2.2, 3.2.1, 3.2.0, 3.1.10, 3.1.9, 3.1.8, 3.1.7, 3.1.6, 3.1.5, 3.1.4, 3.1.3, 3.1.2, 3.1.1, 3.1.0, 3.0.8, 3.0.7, 3.0.6, 3.0.5, 3.0.4, 3.0.3, 3.0.2, 3.0.1, 3.0.0

The project site contains an overview how well these versions were compressed.
Other interesting projects are AngularJS, BackboneJS, Bootstrap, Dojo, Ember, jQuery, Knockout, lodash, React, Socket.IO, ThreeJS, UnderscoreJS and Vue.

Changelog

Best Zopfli parameters so far:
Size Improvement Parameters Found
69732 bytes -5 bytes zopfli --i1000000 --mls8192 --bsr18 --lazy --ohh December 29, 2017 @ 02:57
69737 bytes -5 bytes zopfli --i100000 --mls8192 --bsr18 --lazy --ohh December 28, 2017 @ 13:00
69742 bytes -7 bytes zopfli --i10000 --mls8192 --bsr18 --lazy --ohh December 28, 2017 @ 11:50
69749 bytes -22 bytes zopfli --i1000 --mls8192 --bsr18 --lazy --ohh December 28, 2017 @ 11:19
69771 bytes zopfli --i100 --mls8192 --bsr18 --lazy --ohh December 28, 2017 @ 10:48

If there are multiple parameter sets yielding the same compressed size, only the first one found is shown.

Most recent activity on January 1, 2018 @ 13:46.

Heatmaps

This Zopfli heatmap visualizes how compression changes when modifying the --bsr and --mls parameter.
Cell's contents is the best filesize achieved (in bytes, hover with mouse over cells to see number of iterations).

Good parameters are green, bad are red. The best and worst are bold as well.
The brightness of the blue background color indicates how many iterations were processed:
10,000, 100,000 or 1,000,000.
bsr \ mls
2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768
bsr \ mls
2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768
69894 69897 69855 69977 69973 69972 69975 69991 70012 70294 69913 69914 69890 69982 69921
69806 69797 69899 69979 69975 69813 69904 69912 69914 69826 69824 69838 69889 69851 69813
69829 69831 69880 69876 69867 69882 69840 69801 69835 69840 69839 69823 69803 69898 69802
69821 69866 69813 69815 69799 69814 69804 69817 69797 69839 69798 69820 69757 69787 69755
69813 69822 69812 69813 69856 69822 69798 69807 69796 69821 69924 69855 69803 69779 69801
69800 69819 69819 69979 69830 69818 69808 69801 69797 69811 69826 69812 69760 69808 69808
69816 69824 69812 69815 69818 69815 69794 69826 69792 69829 69831 69818 69786 69829 69781
69800 69832 69873 69818 70006 69817 69832 69802 69813 69834 69835 69815 69764 69805 69779
69810 69809 69797 69822 69818 69818 69755 69832 69767 69804 69789 69779 69795 69788 69805
69799 69796 69878 69922 69815 69922 69827 69828 69795 69828 69834 69811 69749 69794 69801
69798 69815 69794 69920 69820 69944 69806 69828 69796 69837 69803 69816 69782 69791 69791
69794 69804 69800 69827 69817 69917 69794 69829 69801 69804 69798 69800 69739 69774 69802
69818 69805 69865 69813 69810 69918 69795 69800 69792 69835 69827 69813 69747 69785 69802
69826 69823 69814 69911 69916 69917 69806 69826 69796 69829 69830 69815 69745 69786 69774
69788 69804 69794 69917 69820 69923 69798 69836 69797 69830 69827 69812 69732 69804 69793
69818 69813 69816 69820 69827 69830 69808 69804 69795 69841 69804 69811 69761 69800 69793
69800 69811 69816 69918 69833 69922 69806 69835 69794 69830 69833 69812 69751 69780 69806
69791 69819 69793 69816 69813 69818 69793 69811 69800 69828 69835 69811 69759 69802 69807
69796 69826 69869 69924 69820 69915 69796 69835 69795 69802 69836 69816 69738 69778 69800
69804 69807 69829 69923 69810 69914 69795 69833 69819 69837 69804 69811 69766 69786 69770
69808 69816 69814 69981 69821 69819 69797 69830 69797 69832 69830 69819 69770 69805 69799
69794 69793 69808 69818 69819 69877 69817 69795 69793 69828 69836 69812 69790 69773 69765
69787 69806 69803 69816 69812 69946 69789 69804 69806 69827 69840 69824 69811 69813 69778

Due to the Monte Carlo design of my search algorithm, not all parameters have reached the same number of iterations yet:
Iterations Min. Bytes Reduction Coverage
100 69771 bytes 100%
1,000 69749 bytes -22 bytes 100%
10,000 69742 bytes -7 bytes 100%
100,000 69737 bytes -5 bytes 0.87%
1,000,000 69732 bytes -5 bytes 0.29%
10,000,000

KZIP has far less options available for tuning/optimization. I only played around with the number of blocks (parameter -n):
Blocks Min. Bytes Compared To Best Zopfli Compared To Best KZIP
70034 bytes +302 bytes (+0.43%) +211 bytes
71258 bytes +1526 bytes (+2.19%) +1435 bytes
71156 bytes +1424 bytes (+2.04%) +1333 bytes
70029 bytes +297 bytes (+0.43%) +206 bytes
70036 bytes +304 bytes (+0.44%) +213 bytes
69973 bytes +241 bytes (+0.35%) +150 bytes
69886 bytes +154 bytes (+0.22%) +63 bytes
69823 bytes +91 bytes (+0.13%)
69837 bytes +105 bytes (+0.15%) +14 bytes

Non-DEFLATE Algorithms

Archivers based on completely different compression algorithms often produce superior results.
Unfortunately, browsers only support gzip compression at the moment.
Algorithm Program Parameters Size Compared To Best Zopfli
ZPAQ (Wikipedia) zpaq zpaq -method 69 54915 bytes -14817 bytes (-21.25%)
RAR (proprietary) RAR rar a -m5 -md64m -mc63:128t -mt1 60979 bytes -8753 bytes (-12.55%)
LZMA2 (Wikipedia) xz xz -9 62168 bytes -7564 bytes (-10.85%)
Brotli (Wikipedia) brotli brotli -q 11 62318 bytes -7414 bytes (-10.63%)
PPMd (Wikipedia) 7zip 7za a -mx=9 -m0=ppmd 62628 bytes -7104 bytes (-10.19%)
ZSTD (Wikipedia) zstd zstd -19 67397 bytes -2335 bytes (-3.35%)
Burrows-Wheeler transform (Wikipedia) bzip2 bzip2 -9 68539 bytes -1193 bytes (-1.71%)

Detailled Analysis

I wrote a DEFLATE decoder in Javascript. Click the button below to start a client-side analysis of the smallest gzipped files (may take a second):


Notes: pigz is a fast open source multi-threaded implementation of gzip written by one of the original authors of gzip.
However, when using compression level 11, pigz actually switches to the slower Zopfli algorithm and isn't multi-threaded anymore.
KrzyMOD's extensions to Zopfli offer the highest level of configuration and is therefore used for my brute-force search.
Ken Silverman wrote the closed-source KZIP compression program and Jonathon Fowler ported it to Linux.
Defluff was created by Joachim Henke; DeflOpt is a tool by Ben Jos Walbeehm.

website made by Stephan Brumme in 2015 and still improving in 2018.
all timestamps are displayed in central european time. see my changelog.
no flash, not even images or external css files - and everything squeezed into a single html file.
which was handsomely compressed before releasing it into the wild internet - obviously.

please visit my homepage and my blog, too.
email: minime (at) stephan-brumme.com