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

Add option to minimize generated html file #150

Open
qarmin opened this issue Jul 10, 2023 · 2 comments
Open

Add option to minimize generated html file #150

qarmin opened this issue Jul 10, 2023 · 2 comments

Comments

@qarmin
Copy link

qarmin commented Jul 10, 2023

Currently when using plot.to_html(), generated file is really big for big amount of data(my app can generate few plots with several thousands of points).

I found that removing unnecessary new lines and empty points can decrease size of plot by ~30%

I tried to use html/js minifier, but it doesn't work, so I wrote simple regex which do almost same thing

    let mut html = plot.to_html();
    let regex = Regex::new(r"\n[ ]+").unwrap();
    let html = regex.replace_all(&html, "");
@mfreeborn
Copy link
Contributor

My inclination would be that minification would be outside the purview of this crate. There are many established minifiers available, and to bring it into the scope of this crate would just add dependencies and whilst providing a sub-optimal implementation.

When you say that you tried a minifier and it didn't work, can you expand on what happened?

@qarmin
Copy link
Author

qarmin commented Jul 10, 2023

I used https://github.com/wilsonzlin/minify-html, but looks that js created by this library is unsupported yet or non standard.

Code was similar to

use minify_html::{Cfg, minify};

let mut code: &[u8] = html.as_bytes();
let mut cfg = Cfg::new();
cfg.minify_js = true;
let minified = minify(&code, &cfg);

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

No branches or pull requests

2 participants