Skip to navigation Skip to main content
Eleventy
Eleventy Documentation
Stable
2.0.1
Toggle Menu
Eleventy 1.93s
Next.js 70.65s

Memoize

Memoize functions - An optimization used to speed up consecutive function calls by caching the result of calls with identical input

There are many popular libraries to cache or memoize functions (filters, shortcodes, etc): memoize (ESM-only) is one such package. You can use memoize (or any other memoization library) to cache things in your Eleventy Configuration file.

Note that Eleventy 3.0 ships with a memoization layer around the built-in slug, slugify, and inputPathToUrl filters.

eleventy.config.js
import memoize from "memoize";

export default function(eleventyConfig) {
eleventyConfig.addLiquidFilter("htmlEntities", memoize(str => {
return encode(str);
}));
};

Other pages in Configuration: