A tool for smashing your static site. It makes files smaller.

Why Would You Use This?

MrSmashy is a tool designed to “scratch my own itch.” I wanted to server the smallest files possible from my site. I use it for jasonrigden.com. This site has four parts.

  • The main blog is generated by Pelican Pelican. This is under the root directory.
  • A shared resource directory. This is for jquery, photos, etc.
  • A slides directory. This is for reveal.js slideshows.
  • A labs directory for various experiments and projects.

While Pelican can compress my blog files, it does not know about the other directories. I wanted a tool that would compress it all with one command. That is why I wrote and use MrSmashy.

There are other tool out there that do similar work. But the diffence is this is the one that I wrote and use.

How Do I Use it?

It is a simple python program. Just point it at a directory.

python MrSmashy.py /home/jason/www

And it starts smashing files.

How does it work?

MrSmashy walks the directory and is subdirectories. It makes a list of all the files it finds. It then processes each file.

  • If the file is a JPG or PNG, it optimizes the image for the web with Jpegoptim or Optipng.
  • If it is an html file or other good compression canidate, it compresses it. It compresses these file with both Zopfli and Brotli at max compression.

MrSmashy then stores a hash of the file in a TinyDB key value store. Next time MrSmashy runs it will check this hash. If this has has not changed, it will not process the file again.

MrSmashy maybe slow and not too smart, but it will make files for the web as small as possible.

Jason Rigden

Written by

You may remember me from such projects as The Seattle Podcasters Guild, The Talking Cryptocurrency Podcast, or some of my popular Python tutorials.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade