Skip to content

Instantly share code, notes, and snippets.

@ifthenelse
Last active December 19, 2025 16:41
Show Gist options
  • Select an option

  • Save ifthenelse/18cf30d480a3866eaed8677785454ad9 to your computer and use it in GitHub Desktop.

Select an option

Save ifthenelse/18cf30d480a3866eaed8677785454ad9 to your computer and use it in GitHub Desktop.
Terser options for bookmarklets
{
module: false, // bookmarklets are usually classic scripts, not ESM
parse: {
ecma: 2020
},
compress: {
ecma: 2020,
passes: 2,
dead_code: true,
drop_debugger: true,
evaluate: true,
inline: 2,
loops: true,
conditionals: true,
booleans: true,
sequences: true,
comparisons: true,
reduce_funcs: true,
reduce_vars: true,
collapse_vars: true,
// IMPORTANT for bookmarklets:
toplevel: false,
// usually keep console logs during dev; flip to true for release
drop_console: false
},
mangle: {
// IMPORTANT for bookmarklets:
toplevel: false,
// don't mangle property names in injected scripts
properties: false
},
output: {
ecma: 2020,
comments: false,
ascii_only: true,
wrap_iife: true // keeps things self-contained (bookmarklet-friendly)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment