- Stable
3.0.0
Toggle Menu
Eleventy
1.93s
Astro
22.90s
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);
}));
};