Newts Parading Majestically
    Wondering what’s next for npm?Check out our public roadmap! »

    minify-inline-json

    1.1.1 • Public • Published

    minify-inline-json

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

    NPM

    CircleCI

    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

    Install

    npm i minify-inline-json

    DownloadsWeekly Downloads

    52

    Version

    1.1.1

    License

    MIT

    Unpacked Size

    8.48 kB

    Total Files

    6

    Last publish

    Collaborators

    • avatar