- ~1.8kb gzipped ⚡️
- Dependency-free 🎉
- IE9+ ✔️
// Select elements and start.let b = start;// Do something else.;
Step 0: Install
Download the latest release or install with npm.
npm install --save baffle
Step 1: Reference
If you linked baffle directly in your HTML, you can use
window.baffle. If you're using a module bundler, you'll need to import baffle.
// CommonJSlet baffle = ;// ES6;
Step 2: Initialize
To initialize baffle, all you need to do is call it with some elements. You can pass a NodeList, Node, or CSS selector.
// With a selector.let b = ;// With a NodeListlet b = ;// With a Nodelet b = ;
Step 3: Use It
Once you have a baffle instance, you have access to all of the baffle methods. Usually, you'll want to
b.start() and, eventually,
// Start obfuscating...bstart;// Or stop obfuscating...b;// Obfuscate once...b;// You can set options after initializing...b;// Or change the text at any time...btext 'Hi Mom!';// Eventually, you'll want to reveal your text...b;// And they're all chainable...bstarttext 'Hi dad!';
You can set options on baffle during initialization or anytime afterward with
// During initialize;// Any time with set()b;
The characters baffle uses to obfuscate your text. It can be a string or an array of characters.
These are the characters that baffle ignores in your text when obfuscating it. You can pass in an array of characters.
This is the frequency (in milliseconds) at which baffle updates your text when running.
An instance of baffle has six methods, all of which are chainable.
Obfuscates each element once, using
Starts obfuscating your elements, updating every
Stops obfuscating your elements. This won't reveal your text. It will only stop updating it. To reveal it, use
Reveals your text over
0), with the option to delay by
Updates instance options using the passed
optionsobject. You can set any number of keys, even while running.
Updates the text in each element of your instance using function
fn, which receives the current text as it's only parameter. The value returned from
fnwill be used as the new text.