Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/haensl/minify-inline-json
Node.js module to minify inlined/embedded JSON data within script tags.
https://github.com/haensl/minify-inline-json
embedded html inline json json-data json-ld json-schema minify script
Last synced: about 2 months ago
JSON representation
Node.js module to minify inlined/embedded JSON data within script tags.
- Host: GitHub
- URL: https://github.com/haensl/minify-inline-json
- Owner: haensl
- License: mit
- Created: 2018-03-15T02:12:35.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-06-16T17:55:47.000Z (7 months ago)
- Last Synced: 2024-10-06T18:17:09.872Z (3 months ago)
- Topics: embedded, html, inline, json, json-data, json-ld, json-schema, minify, script
- Language: JavaScript
- Size: 133 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# minify-inline-json
Node.js module to minify inlined/embedded JSON data within script tags.[![NPM](https://nodei.co/npm/minify-inline-json.png?downloads=true)](https://nodei.co/npm/minify-inline-json/)
[![CircleCI](https://circleci.com/gh/haensl/minify-inline-json.svg?style=svg)](https://circleci.com/gh/haensl/minify-inline-json)
## Installation
### NPM
`npm i --save minify-inline-json`
### Yarn
`yarn add minify-inline-json`
## Usage
### Synopsis
```javascript
/**
* Minify inline JSON data in the given string.
* When minifyInlineJson() encounters a script tag with JSON mime type,
* e.g.
* {
* // ...
* }
* it will minify the JSON found within the script tag.
*
* @param {string} html the string to process.
* @param {object} options configuration options.
* @returns {string} the processed string.
*/
minifyInlineJson(html, options);
```### Example
```javascript
const minifyInlineJson = require('minify-inline-json');
const fs = require('fs');const html = fs.readFileSync('index.html', 'utf8');
minifyInlineJson(html);
```### Options
#### mimeTypes `Array | string`
**Default:** `['application/json', 'application/ld+json']`
Specify the mime type(s) of scripts to minify JSON data in.
### [Changelog](CHANGELOG.md)
### [License](LICENSE)