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
Minify ansi_up.js
file
#77
Comments
Hi, |
Imho, minification is best left to be done by the consumer via their bundler (esbuild, vite, webpack, etc). If you are really nice, you could publish a minified file in the npm package, but it needs additional tooling. |
@silverwind The issue is that esbuild cannot minify the And @drudru here are the stats you where looking for:
I used the following Python code to get these results: from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
from fastapi.middleware.gzip import GZipMiddleware
import uvicorn
app = FastAPI()
app.mount("/", StaticFiles(directory="files"), "static")
app.add_middleware(GZipMiddleware, minimum_size=512)
uvicorn.run(app, host="0.0.0.0", port=8000) And used |
Okay, I think at least these rgx strings should be put in minified variant into the source here, the rest can be done with a minifier on the user side. |
Wow @dosisod - excellent work. The next major release will be about moving to the module format, API enhancements, and other tiny features. Once that is out, work will be done on this a minor number release. |
Currently the
ansi_up.js
file in the root of this project is about 23KB. Providing a minified version of this file would be nice so that you don't have to vendor and minify the file yourself.In my testing I was able to get the file size down to 9.2KB using esbuild:
This is an improvement, but looking at the file you'll find that there is a lot of whitespace due to the
rgx
andrgxG
templates:By manually removing the comments and whitespace from the templates I was able to get the file size down to 6.5KB:
Manually minifying the templates for each release would be a pain though, so perhaps changing how the
rgx
functions are called would be a better option (perhaps by using string concatenation or de-indenting the whitespace).I have no issue manually minifying the file for my own project, but having a minified version that others could use would be nice. I don't know what the release process looks like for this library, but I would be more than happy to write a build script that automates this minification process.
Thanks!
The text was updated successfully, but these errors were encountered: