minifykr

Concatenate and minify XML files in krpano projects

npm install minifykr
37 downloads in the last month

minifykr.js

A script to concatenate and minify XML files in krpano projects.

No tests yet, shamefully.

Installation

npm install [-g] minifykr

Usage

As script

minifykr [ --noEncrypt ] [ inputFile ] [ outputFile ]

  • The default value for inputFile is main.xml

  • The default value for outputFile is INPUT_FILE.min.xml

  • When --noEncrypt is specified, the output will be encrypted using kencrypt. This requires kencrypt to be in the PATH

As module

var minifykr = require('minifykr');

var minifiedData = minifykr.data(inputData);

minifykr.file(inputFile, outputFile, encrypt)

Features

krpano projects often consist of a large number of XML files, which have to be loaded by the browser. This script minifies the XML code, merging all the files and removing unnecessary code, such as comments or spaces between XML tags.

This script recursively transverses all the files which are included in inputFile through <include> tags, minifies their code and writes the result to outputFile. Minifying does the following:

  • removes comments

  • removes characters between tags

  • removes text inside tags which are not <data> or <action>

Known issues/missing features

  • <include> tags inside other tags are not parsed

This script uses a modified version of node-elementtree to parse and generate XML. The modification removes the automatic attribute ordering, to keep the order of the url and alturl attributes.

There's also a python implementation, which does not keep the attribute order.

npm loves you