# strip-comment

> Strip js, css, and html comments

Latest version **1.1.3** (published 2015-03-09) · ISC license · 0 weekly downloads

## Install

```sh
npm install strip-comment
pnpm add strip-comment
yarn add strip-comment
bun add strip-comment
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.3 |
| Published | 2015-03-09 |
| First published | 2014-12-28 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | douzi |
| Maintainers | douzi |
| Keywords | strip, comments, comment, remove, js, css, html |

## Links

- npm: https://www.npmjs.com/package/strip-comment
- Repository: https://github.com/douzi8/strip-comment
- Issues: https://github.com/douzi8/strip-comment/issues
- npm.io page: https://npm.io/package/strip-comment

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.1.3 (latest) — 2015-03-09
- 1.1.2 — 2015-03-09
- 1.1.1 — 2015-03-08
- 1.0.8 — 2015-02-06
- 1.0.7 — 2015-02-05
- 1.0.6 — 2015-01-05
- 1.0.5 — 2015-01-05
- 1.0.4 — 2014-12-31
- 1.0.3 — 2014-12-28
- 1.0.2 — 2014-12-28
- 1.0.1 — 2014-12-28
- 1.0.0 — 2014-12-28

## README

strip-comment
=============

Strip js, css, and html comments.
## Install
```
npm install strip-comment --save
```
### test
```
mocha
```
### demo
```html
<style>
p {
    color: red;
    /* Css line comment */
    text-align: center;
}
/*
 * Css block comment 
 */
</style>
<!-- html comment -->
<p>This is a paragraph.</p>
// html content

<script>
/*
 * Js block comemnt
 */
function displayMsg() {
  // Js line comment
  alert("Hello World!")
}
</script>

```
```js
var fs = require('fs');
var html = fs.readFileSync('./index.html', { encoding: 'utf8' });
var strip = require('strip-comment');

strip(html);  // Strip js css and html comments.
```
## API
### strip(code, keep)
Strip html css and js comments
  * {string} ``code`` required
  * {boolean} ``keep`` [keep = false]  
  Keep the source code lines and columns

### .js(code, keep)
Strip js comments
  * {string} ``code`` required
  * {boolean} ``keep`` [keep = false] 
```js
var js = 'var a = 3; // comment'
strip.js(js);
strip.js(js, true);     // keep code lines
```

### .css(code, keep)
Strip css comments
  * {string} ``code`` required
  * {boolean} ``keep`` [keep = false] 
```js
var css = 'h2 { /* comment */ font-size : 18px; }'
strip.css(css);
```

### .html(code, keep)
Strip html comments
  * {string} ``code`` required
  * {boolean} ``keep`` [keep = false]
```js
var html = '<!-- html comment --><div></div>'
strip.html(html);
```

---
_Source: https://npm.io/package/strip-comment · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
