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

Can we minimize more? #6

Open
agroden opened this issue Dec 22, 2017 · 4 comments
Open

Can we minimize more? #6

agroden opened this issue Dec 22, 2017 · 4 comments
Assignees
Labels

Comments

@agroden
Copy link
Owner

agroden commented Dec 22, 2017

Is the output of the minimizer truly the most minimized it could be?

@agroden agroden self-assigned this Dec 22, 2017
@agroden
Copy link
Owner Author

agroden commented Dec 23, 2017

Upon closer examination, we could definitely minimize more - some statements that are deliberately broken up (for instance, on a second line) for style remain on a different line in the minimized output.

This could be fixed by keeping track of brackets and parenthesis during the initial grouping of tokens.

@agroden
Copy link
Owner Author

agroden commented Dec 24, 2017

minimizer.py is now keeping track of brackets and closures and will not create a new token group unless the brackets have been balanced out. This will ensure that lines that have been split up for style will be reassembled on the same line.

@jcrubino
Copy link

Can we tree shake then minimize?

@agroden
Copy link
Owner Author

agroden commented Nov 20, 2018

Can we tree shake then minimize?

Interesting suggestion - tree shaking is difficult for dynamic languages, even JavaScript relies on the import and export syntax to maintain a semblance of static structure in order to conservatively remove outgoing code. I would prefer to stick to static analysis methods like vulture or pyan as the alternative (something like pycallgraph, maybe?) seems like it would require more knowledge about how the program is executed than I would like the minimizer to care about.

Vulture seems like a plausible path forward on this, such that a user could specify an option to search for and remove dead code and provide the minimizer with a confidence threshold. I will look into it.

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

No branches or pull requests

2 participants