Imaginator
An Express middleware that converts image tags to use data URIs instead of image files an HTML document.
Installation
> npm install --save imaginator
Usage
const express = ;const path = ;const imaginator = ;const app = ;app;app;app;
imaginator(publicDirectory, selector = 'img')
publicDirectory
: The path to the directory where the hosted public files (including the images) are stored. In most cases, it should be set topath.join(__dirname, 'public')
.selector
: The CSS-style selector for the tags to be affected. Its default value is'img'
i. e. Allimg
tags will be affected.
Example
index.html
before applying Imaginator:
HiHello world!
index.html
after applying Imaginator:
HiHello world!
Made with ❤ by Param.