A Python package for optimizing HTML, JS, CSS, and JSON files in a directory.
To achieve this, the project copies the selected folder to a new "compressed" folder inside the selected directory and applies optimizations to supported file types.
It automatically detects .gitignore files and skips ignored files during copying.
Currently supported file types:
.html.js.css.json
Run main.py to launch the folder selection and optimization process.
html_optimiser/— main package codemain.py— entry pointsetup.py— package setupREADME.md— documentation
-
Open
html_optimiser/optimisation_def.py. -
Create a new function for your file type (e.g.,
optimize_xml).- The function should take a file path as its only argument.
- It should read and write the file itself, allowing you to handle encoding as needed.
- The function should overwrite the file it is given (the file is already copied before optimisation).
-
Register your function in the
optimisation_mapdictionary, mapping the new file extension to your function. -
Document your function with a clear docstring describing its purpose and usage.
Example:
def optimize_xml(file_path):
"""
Optimize an XML file by removing unnecessary whitespace.
Args:
file_path (str): Path to the XML file to optimize.
"""
# Add your XML optimisation logic hereFeel free to open issues or submit pull requests for new file type support!