# web-resource-inliner [![build status](https://api.travis-ci.org/jrit/web-resource-inliner.svg)](http://travis-ci.org/jrit/web-resource-inliner)
Brings externally referenced resources, such as js, css and images, into a single file.
For example:
```html
```
is replaced with
```html
```
Javascript references are brought inline, and images in the html and css blocks are converted to base-64 data: urls.
By default, all links and scripts are inlined, plus any images under 8KB, however this behavior can be overrided via several options.
## Getting Started
```
npm install web-resource-inliner
```
## Usage Examples
For a number of usage examples, see ./test/spec.js and the associated test.* and test_out.* files in ./test/cases/
## Methods
#### html( options, callback )
Expects options.fileContent to be HTML and creates a new HTML document. `callback` will be called on completion or error with arguments `( error, result )`.
#### css( options, callback )
Expects options.fileContent to be CSS and creates a new CSS document. `callback` will be called on completion or error with arguments `( error, result )`.
## Options
#### `fileContent`, required
This is the HTML or CSS content to be inlined, you should provide HTML to the `html()` method and CSS to the `css()` method or you will get errors or garbage output.
#### `inlineAttribute`, string, default `data-inline`
Sets the attribute that is used to include/exclude specific resources based on the default behavior for the resource type. For example, if `scripts` is set to `false`, an individual script can be inlined by adding the attribute to the `script` tag like ``. On the other hand, if `images` are set to be inlined by default, a specific image can be excluded by adding `-ignore` to the end of the `inlineAttribute` like ``. In CSS, a comment is required at the end of the line to perform the same thing, such as `/*data-inline*/` or `/*data-inline-ignore*/`.
#### `images`, Boolean or Number, default `8`
When true, inline images unless they have an exclusion attribute (see inlineAttribute option). When false, exclude images unless they have an inclusion attribute (see inlineAttribute option). When a number, inline images only when the base64 content size is less than the number of KBs. For example, the default is to only inline images less than 8KB.
#### `svgs`, Boolean or Number, default `8`
When true, inline SVG `