choojs / choojs/nanohtml

Stripping comments in production builds

Open
#117 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
688
Forks
48
PR merge metrics
No merged PRs in 30d

Description

It looks like we preserve comments when running the browserify transform on the tagged template literals [source](https://github.com/choojs/nanohtml/blob/master/lib/browserify-transform.js#L112-L114).

I'd like to remove all comments from production builds in order to:

1. Not accidentally leak information/context that I did not want to leak in prod.
2. Reduce build size.

First things that come to mind:

# Potential Solution 1

`browserify -t [nanohtml --strip-comments ]` strips comments

---

FWIW I wouldn't mind if stripping comments was the default or if nanohtml just always stripped comments since I never use comments in the browser. I only use HTML comments while reading code.

.. But I recognize that other people might want them in by default / that could maybe lead to less confusion maybe.. so whatever works!

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading lib/browserify-transform.js around lines 112-114 and trace how the Browserify transform handles comments in tagged template literals. Determine how comment stripping should be selected or defaulted, then verify that production output contains no comments while the surrounding template output remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, web-dev
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.