Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including minify-inline-json with all npm packages installed. Try it out:

var minifyInlineJson = require("minify-inline-json")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

minify-inline-json v1.0.1

Minify inlined/embedded JSON data within script tags

minify-inline-json

Node.js module to minify inlined/embedded JSON data within script tags.

NPM

Build Status

Installation

NPM

npm i --save minify-inline-json

Yarn

yarn add minify-inline-json

Usage

Synopsis

/**
 * Minify inline JSON data in the given string.
 * When minifyInlineJson() encounters a script tag with JSON mime type,
 * e.g.
 *  <script type="application/json">{
 *    // ...
 *  }</script>
 * 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

const minifyInlineJson = require('minify-inline-json');
const fs = require('fs');

const html = fs.readFileSync('index.html', 'utf8');
minifyInlineJson(html);

Options

mimeTypes Array<string> | string

Default: ['application/json', 'application/ld+json']

Specify the mime type(s) of scripts to minify JSON data in.

Changelog

License

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free