Minify html, css and java script files with services of Toptal,
through the use of their API and optimize the images of your project to reduce its size.
The script is written in python.
- The project has been perform in Linux platform and has not been probed in others platforms.
- The original project is not modified, a copy of the project is created.
Follow the next steps:
- Download the folder and place it in the same parent folder as your project. For example:
parent_folder │ └───my_project │ └───minify
- Create a virtualenvironment and install the packages described in requirements.txt.
- Run command:
minify.py source_path destination_path
For example, assuming I have a project named example and I want to put the folder with the minified files
in the parent folder of example, the command is:
minify.py ./example ./
- And the following folder will be created:
parent_folder
│
└───example
│
└───minify
│
└───prod
│
└───example
- In prod folder there will be copy of example project with the minified files and compressed images.
- source_path and destination_path are taken from parent folder of minify folder.
- By default the copy of the project is created inside a folder named prod and the optimization quality is of 65. These and others parameters can be changed minify/settings.py.
minify/
│ minify.py: main file that containing project logic.
│ settings.py: file that contain the configurations.
│ utils.py: file that contain helper functions for minify.py
Any pull request are welcome.
- Perform unit tests.
- Join css files into a main css file.
- Use some API service to convert images to webp format.
https://www.toptal.com/developers/cssminifier/python
https://www.toptal.com/developers/javascript-minifier/python