Registry / devops / jlto
library1.5.4jsnpmunverified

JLTO (Jinja Like Templates Optimizer) is a Node.js tool for minifying and optimizing templates from Jinja-like engines (Nunjucks, Twig.js, LiquidNode, etc.). As of v1.5.4, it strips whitespace, removes comments, and optionally minifies HTML via html-minifier-next. It supports custom delimiters and engine-specific syntax. Released under MIT, it is a niche alternative to build-tool plugins, offering programmatic optimization via optimizeString(). It is actively maintained with frequent patch updates.

npm install jlto
INSTALL
IMPORT
SIG · JLTO
J
jlto
devopsjavascriptv1.5.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
const jlto = require('jlto')
CJS only; no ESM exports as of v1.5.4
optimizeString
const { optimizeString } = require('jlto')
Also available via default import
Grunt integration
require('jlto') in Grunt task (CJS)
import jlto from 'jlto'
ESM import is not supported; use CJS require

Demonstrates basic usage: require jlto and call optimizeString with a template to remove extra whitespace and spaces in tags.

const jlto = require('jlto'); const template = ` {{ hello }} {{ "<John & Paul> ?" | escape }} {{ '2.7' | round }}{% if product %}Product exists.{% endif %} `; jlto.optimizeString(template).then((optimizedTemplate) => { console.log(optimizedTemplate); // Output: {{hello}} //{{"<John & Paul> ?"|escape}} //{{'2.7'|round}}{%if product%}Product exists.{%endif%} });
Debug
Known issues
gotchaoptimizeString always returns a Promise; must be awaited or handled with .then()
fix
Use await or .then() on optimizeString calls.
affects: >=1.0.0
gotchaMinifyHtml option requires html-minifier-next as a peer dependency; must be installed separately
fix
Run npm install html-minifier-next or skip minification.
affects: >=1.5.0
gotchaDefault delimiters are for Jinja-like engines; custom delimiters must be specified in options
fix
Pass expressionStart, expressionEnd, etc. options to customize for non-default engines.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: jlto.optimizeString is not a function
Using default import instead of named import or require
fix
Use const jlto = require('jlto'); then jlto.optimizeString(...)
Error: Cannot find module 'html-minifier-next'
Optional dependency not installed when minifyHtml: true
fix
Install html-minifier-next: npm install html-minifier-next
Upgrade
Version history
1.5.4latest on npm
Audit
Dependencies
html-minifier-nextoptionalUsed for HTML minification when minifyHtml option is true
Agent activity
7 hits · last 30 days
node
6
Resources
packagejlto
jlto — npm install jlto · libregistry