> For the complete documentation index, see [llms.txt](https://developers.spiffy.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.spiffy.co/spiffyjs/methods.md).

# Methods

### .config(*configObj*)

Modify the global Spiffy.js [config](https://developers.spiffy.co/spiffyjs/config.md) before `spiffy.load()`

* `configObj` - Object of [config properties](https://developers.spiffy.co/spiffyjs/config.md)

### .load(*account*)

Start up and mount Spiffy.js for your account

* `account` - String of Spiffy account subdomain

### .debug()

Put Spiffy.js into debug mode which logs helpful developer details to the console

### .checkout(*url, \[configObj]*)

Create or access existing checkout instance object. Returns a checkout object

* `url` - String of the URL of the checkout
* `configObj` - Optional object of [checkout settings](https://developers.spiffy.co/spiffyjs/introduction/settings.md)

### .rescan()

Re-scan the page for Spiffy embeds and mount any that aren't mounted yet. Returns the number mounted.

You rarely need this. `<spiffy-element>` and the other embed tags mount themselves whenever they're added to the page, including elements your app inserts after load in a single-page app. `.rescan()` is only for [compatibility-mode](https://developers.spiffy.co/spiffyjs/config.md) containers (plain `<div>`s used in place of the custom tags), which the browser can't announce on their own.

## Add/Remove Event Listeners

The `.on()` and `.off()` methods can be used globally on the `spiffy` object for global-only events as well as catch-all event handlers for events specific to major sub-objects such as Checkouts

These methods can also be used directly on a Checkout object to scope event handling to that specific checkout.

### .on(*event, handler*)

Adds a global event listener to all Spiffy objects

* `event` - String of event name
* `handler` - Function to be ran when event is triggered
  * The handler function will get varying `data` objects passed in (depending the event being fired)

```javascript
spiffy.on('ready', function () {
    // do things here when spiffy is ready!
})
```

### .off(*event, handler*)

Removes global event listeners from Spiffy objects

* `event` - String of event name
* `handler` - Function to be ran when event is triggered
  * NOTE: The handler function must match the exact function used when adding the event listener

```javascript
spiffy.off('ready', function () {
    // do things here when spiffy is ready!
})
```

##
