@zippytech/uglified

Checks if the code is minified

Usage no npm install needed!

<script type="module">
  import zippytechUglified from 'https://cdn.skypack.dev/@zippytech/uglified';
</script>

README

uglified

Checks if the code is minified.

Install

$ npm install @zippytech/uglified --save

Usage

var minified = require('@zippytech/uglified')

console.log(minified) // `true` or `false`

Features

  • targeted at browser environments, when you want to know at runtime if the code is minified or not
  • full test-coverage
  • simple implementation

Module name inspiration

The module does not have any relation to uglify-js, but the module name minified was taken on npm, so we thought a good alternative name would be uglified. Probably not the best choice, but does the job anyway.

Implementation details

It uses a function with only an arg (which is never used in the function body), and the function body only containing a comment. It then tests if the toString of the function returns the same value as the original function code. If it does not, the code is probably minified, so returns true.

LICENSE

Apache2