This is a straight copy from a878bf0ba0 paired with a tiny change to use the new quote_chars option.
a878bf0ba0
Exported source code from changeset fdfa1b187681 from https://bitbucket.org/dcs/jsmin without modifications.