Jekyll Replace Image

A Jekyll plugin to replace img tags with custom elements during site generation.

A Jekyll plugin to replace img tags with custom elements during site generation.

What it does

It runs a regular expression to find HTML img tags against the output of each page and replaces matches with a user-defined replacement.

There are a number of custom elements you can use, such as progressive-img, amp-img and (my very own) hy-img.

Note that replacing images during site generation is necessary for lazy-loading, because the browser will start loading any img tag as soon as it is parsed, before it can be touched by client side code.

Why

  1. Lazy-loading images increases page load speed and is recommended by Google.
  2. So you can use the ![alt](src) syntax for images without polluting your posts with lengthy HTML tags.