Skip to content

Configuration

Pageflare is configured through a pageflare.jsonc file in your input directory. All options have sensible defaults — the config file is optional unless you want to customize behavior.

Run --init to generate a fully-commented config file with every option set to its default value:

Terminal window
pageflare dist/ --init

This writes dist/pageflare.jsonc. Edit it to suit your site.

The file uses JSONC (JSON with comments). You can use // and /* */ comments freely:

{
// Minification
"minify_html": true,
"minify_css": true,
"minify_js": true
}

Pageflare looks for the config file at <input>/pageflare.jsonc. To use a different path, pass -c / --config:

Terminal window
pageflare dist/ --config ./config/pageflare.jsonc

Control whether HTML, CSS, and JavaScript are minified.

OptionTypeDefaultDescription
minify_htmlbooleantrueMinify HTML files — collapse whitespace, remove optional tags and comments
minify_cssbooleantrueMinify CSS — remove whitespace, shorten values, deduplicate rules
minify_jsbooleantrueMinify JavaScript — remove whitespace, shorten identifiers, tree-shake dead code
{
"minify_html": true,
"minify_css": true,
"minify_js": true
}

Control how JavaScript is deferred to improve initial page load.

OptionTypeDefaultDescription
js_deferbooleantrueDefer non-critical JavaScript until after the page is interactive
js_defer_methodstring"user-interaction"When to load deferred scripts: "user-interaction" (first scroll/click/keypress) or "defer" (standard HTML defer)
js_defer_excludesstring[][]Array of script URL patterns to exclude from deferral (substring match)
js_defer_timeoutnumber10000Fallback timeout in milliseconds — deferred scripts load after this delay even without user interaction
{
"js_defer": true,
"js_defer_method": "user-interaction",
"js_defer_excludes": [
"analytics.js",
"/critical/"
],
"js_defer_timeout": 10000
}

js_defer_method values:

  • "user-interaction" — Scripts load on the first user interaction (scroll, click, or keypress), with js_defer_timeout as a fallback. This maximizes Time to Interactive (TTI) improvement.
  • "defer" — Uses the standard HTML defer attribute. Scripts run after the document is parsed but do not wait for user interaction.

js_defer_excludes accepts partial URL strings. Any script whose src contains a listed substring is excluded from deferral:

{
"js_defer_excludes": [
"stripe.js", // Payment scripts that must load immediately
"/vendor/init" // Initialisation scripts required on first paint
]
}

Control lazy loading and automatic dimension injection for images and iframes.

OptionTypeDefaultDescription
lazy_load_imagesbooleantrueAdd loading="lazy" to images below the fold
lazy_load_iframesbooleantrueAdd loading="lazy" to iframes
lazy_load_excludesstring[][]Array of image URL patterns to exclude from lazy loading
add_image_dimensionsbooleantrueDetect and inject width and height attributes on <img> tags that are missing them, preventing layout shift (CLS)
{
"lazy_load_images": true,
"lazy_load_iframes": true,
"lazy_load_excludes": [
"logo.png",
"/hero/"
],
"add_image_dimensions": true
}

Images near the top of the page (above the fold) are automatically excluded from lazy loading regardless of lazy_load_excludes.


OptionTypeDefaultDescription
font_display_swapbooleantrueInject font-display: swap into @font-face rules so text remains visible while custom fonts load
self_host_google_fontsbooleantruePRO Download Google Fonts and serve them from your own domain, eliminating the third-party DNS lookup
font_unicode_rangebooleantruePRO Generate unicode-range descriptors for self-hosted fonts to avoid loading character sets not used on the page
{
"font_display_swap": true,
// Pro features
"self_host_google_fonts": true,
"font_unicode_range": true
}

OptionTypeDefaultDescription
preconnect_hintsbooleantrueInject <link rel="preconnect"> for third-party origins detected in the page, reducing connection latency
speculation_rulesbooleantruePRO Inject the Speculation Rules API to prerender likely-next pages in supporting browsers
spa_modebooleantruePRO Enable single-page app navigation using the View Transitions API for instant client-side page changes
{
"preconnect_hints": true,
// Pro features
"speculation_rules": true,
"spa_mode": true
}

OptionTypeDefaultDescription
critical_cssbooleantruePRO Extract and inline above-the-fold CSS, then load the full stylesheet asynchronously to eliminate render-blocking CSS
{
// Pro feature
"critical_css": true
}

OptionTypeDefaultDescription
defer_background_imagesbooleantruePRO Defer off-screen CSS background images using IntersectionObserver
youtube_facadesbooleantruePRO Replace YouTube embeds with lightweight click-to-load facades, eliminating ~500 KB of third-party JavaScript on initial load
remove_wp_bloatbooleantruePRO Remove WordPress-specific bloat: emoji scripts, redundant meta tags, and unused query strings
platform_imagesbooleantruePRO Convert images to next-gen formats (WebP/AVIF) and generate responsive srcset attributes
hash_filenamesbooleantruePRO Append content hashes to asset filenames for long-term cache control, then update all references in HTML and CSS
{
// Pro features
"defer_background_images": true,
"youtube_facades": true,
"remove_wp_bloat": false, // Disable if not a WordPress site
"platform_images": true,
"hash_filenames": true
}

A config file with all options explicit (as generated by pageflare --init):

{
// ── Minification ─────────────────────────────────────────
"minify_html": true,
"minify_css": true,
"minify_js": true,
// ── JavaScript Loading ────────────────────────────────────
"js_defer": true,
"js_defer_method": "user-interaction",
"js_defer_excludes": [],
"js_defer_timeout": 10000,
// ── Images ────────────────────────────────────────────────
"lazy_load_images": true,
"lazy_load_iframes": true,
"lazy_load_excludes": [],
"add_image_dimensions": true,
// ── Fonts ─────────────────────────────────────────────────
"font_display_swap": true,
"self_host_google_fonts": true, // Pro
"font_unicode_range": true, // Pro
// ── Performance Hints ─────────────────────────────────────
"preconnect_hints": true,
"speculation_rules": true, // Pro
"spa_mode": true, // Pro
// ── CSS ───────────────────────────────────────────────────
"critical_css": true, // Pro
// ── Other ─────────────────────────────────────────────────
"defer_background_images": true, // Pro
"youtube_facades": true, // Pro
"remove_wp_bloat": true, // Pro
"platform_images": true, // Pro
"hash_filenames": true // Pro
}

Pro-only options are silently ignored on the Free tier — you can leave them set to true in your config without causing errors.