Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include minify_css and minify_js in the public API #67

Closed

Conversation

Jayman2000
Copy link

@Jayman2000 Jayman2000 commented Jan 21, 2022

I haven’t finished adding them to the API for all of the different languages yet. Here’s what I have so far:

  • Rust
  • CLI
  • Node.js
  • Python
  • Ruby

Fixes #66.

@Jayman2000
Copy link
Author

I took a look at creating bindings for Node.js and Ruby, but that code is too far over my head. To put things in perspective, I only started learning Rust less than a month ago, but I understand Rust much better than I understand JavaScript or Ruby.

That’s not to say that I’ll never finish this PR, just that I’m going to focus on something else for a while.

@wilsonzlin
Copy link
Owner

Hey, thanks for creating the PR and raising the issue. I think this is an interesting idea, but currently I'm against it for a few reasons:

  • The internal usage of the JS and CSS minifiers is an implementation detail, and exposing them would limit or complicate changing their usage/behaviour when beneficial or necessary. For example, esbuild has been replaced with minify-js, a JS minifier I wrote from scratch fully in Rust, which has different configuration, usages, semantics, rules, and output types.
  • The JS and CSS minification libraries are publically available and minify-html does not have much additional code when using them, so it's possible to easily import and use them alongside minify-html and we would not be providing much additional value.
  • We would probably need to also clone the API across all library variants and languages, and JS and CSS minification will most likely have far more complicated function signatures and usage patterns than minify-html. Consider all the deep configuration options, error handling, and threading, that must be exposed, tested, and described. It's already quite difficult to merely implement the current simple minify-html APIs in other languages, so this would be adding a lot more effort and complexity.
  • We'd most likely have to reimplement most if not all of the functionality of the libraries, and also track them regularly and provide frequent updates (including breaking version changes) even if nothing has changed with regards to the main functionality (HTML minification). From my experience with esbuild-lib, this is neither fun nor easy.

I'm going to close this PR and corresponding issue for now for housekeeping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Include minify_css and minify_js in the public API
2 participants