{"id":16653719,"url":"https://github.com/baseplate-admin/flask_strip_whitespace","last_synced_at":"2025-06-11T00:33:39.482Z","repository":{"id":57430786,"uuid":"431184225","full_name":"baseplate-admin/flask_strip_whitespace","owner":"baseplate-admin","description":"A Powerful HTML white space remover for Flask","archived":false,"fork":false,"pushed_at":"2023-05-03T11:21:57.000Z","size":113,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-12T23:46:10.162Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/baseplate-admin.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-23T16:58:44.000Z","updated_at":"2021-12-29T03:52:40.000Z","dependencies_parsed_at":"2025-03-12T17:41:33.820Z","dependency_job_id":"783d626a-c7be-461f-bff4-6a67b2079829","html_url":"https://github.com/baseplate-admin/flask_strip_whitespace","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baseplate-admin%2Fflask_strip_whitespace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baseplate-admin%2Fflask_strip_whitespace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baseplate-admin%2Fflask_strip_whitespace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baseplate-admin%2Fflask_strip_whitespace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/baseplate-admin","download_url":"https://codeload.github.com/baseplate-admin/flask_strip_whitespace/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baseplate-admin%2Fflask_strip_whitespace/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259175889,"owners_count":22817081,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T09:46:55.561Z","updated_at":"2025-06-11T00:33:39.438Z","avatar_url":"https://github.com/baseplate-admin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"HTML Whitespace remover for Flask\n==================================\n|Pepy.tech Badge| |PyPi Version Badge| |Python Versions Badge| |License Badge| |Code Style|\n\n.. |Pepy.tech Badge| image:: https://static.pepy.tech/personalized-badge/flask-strip-whitespace?period=week\u0026units=international_system\u0026left_color=grey\u0026right_color=orange\u0026left_text=Downloads\n   :target: https://pepy.tech/project/flask-strip-whitespace\n\n.. |PyPi Version Badge| image:: https://badge.fury.io/py/flask-strip-whitespace.svg\n    :target: https://badge.fury.io/py/flask-strip-whitespace\n\n.. |Python Versions Badge| image:: https://img.shields.io/pypi/pyversions/flask-strip-whitespace\n    :alt: PyPI - Python Version\n    :target: https://github.com/baseplate-admin/flask_strip_whitespace/blob/main/setup.py\n\n.. |License Badge| image:: https://img.shields.io/pypi/l/flask-strip-whitespace\n   :alt: PyPI - License\n   :target: https://github.com/baseplate-admin/flask_strip_whitespace/blob/main/LICENSE\n   \n.. |Code Style| image:: https://img.shields.io/badge/code%20style-black-000000.svg\n   :alt: Code Style\n   \nIntroduction :\n--------------\nA powerful tool to optimize Flask rendered templates\n\nWhy use \"flask_stip_whitespace\" ?\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n*   Adds line break to InlineJS.\n*   It can automagically minify inline CSS, JS.\n*   Removes \u003c!--prettier-ignore--\u003e from HTML.\n*   It speeds up website by reducing the HTML size.\n*   It compiles regex at runtime. So it's blazing fast.\n*   Its mostly based on C ( gzip ) and Rust ( `minify-html \u003chttps://pypi.org/project/minify-html/\u003e`__  ) libraries.\n*   Significantly lower bytes transferred when working with frameworks like AlpineJs ( Almost fully working \u0026 Please open a issue in the `Issue Tracker \u003chttps://github.com/baseplate-admin/flask_strip_whitespace/issues\u003e`__ if you encounter any bug) \u0026 Petite Vue.\n*   Is very customizable. ( You can configure lower level `minify-html \u003chttps://github.com/wilsonzlin/minify-html/blob/master/python/src/lib.template.rs/\u003e`_ rust bindings and also the lower level `python \u003chttps://github.com/juancarlospaco/css-html-js-minify/blob/master/css_html_js_minify/html_minifier.py/\u003e`_ bindings from flask's configuration )\n\n\nWhy shouldn't you use \"flask_stip_whitespace\" ?\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n*   You don't like having unnecessary ';;' in your HTML. ( If you know any regex to fix this please put a pull request )\n\n*   Although I tried my best to use Compiled Language for Optimizations. It can still be sub miliseconds ( \u003e 0.001 ) slower compared to normal Flask Rendering. ( If you know any way to improve performance, please put a pull request )\n\n\nRequirements :\n--------------\n\n*    `python-strip-whitespace \u003chttps://github.com/baseplate-admin/python_strip_whitespace\u003e`_\n*    Flask\n*    Python 3 ( Should work with all version? )\n*    Brotli ( or BrotliPy; pypy ) | ( Optional )\n*    ZSTD ( Optional ) \n\nUser guide :\n============\n\nInstallation :\n--------------\n\nInstall with pip from pypi (No extra dependencies)::\n\n      $ python -m pip install flask_strip_whitespace\n\nInstall with pip with Brotli support::\n\n      $ python -m pip install flask_strip_whitespace[brotli]\n\nSame but with Zstandard support::\n\n      $ python -m pip install flask_strip_whitespace[zstd]\n\n\n\n\nInstall with pip from github ( Development | Not Recommended for Production )::\n    \n      $ python -m pip install https://codeload.github.com/baseplate-admin/flask_strip_whitespace/zip/refs/heads/main\n\n\nThen include it in your flask project:\n   \n.. code-block:: python\n\n     from flask_strip_whitespace.middlewares import HTMLStripWhiteSpaceMiddleware\n\n     # Declare a dictionary to store config. \n     # Note that this dictionary must be called before adding wsgi middleware.\n     STRIP_WHITESPACE_CONFIG : dict = {}\n\n     app = Flask(__name__)\n     app.wsgi_app = HTMLStripWhiteSpaceMiddleware(app.wsgi_app, config=STRIP_WHITESPACE_CONFIG) # Note that config is a python dictionary \n\nCustomization :\n===============\n\nChange Lower Level Bindings :\n-----------------------------\n\nRust :\n~~~~~~\n\nThe module allows `rust \u003chttps://github.com/wilsonzlin/minify-html\u003e`_ minifier options to be changed from Flask's environ variables. If you would like to change any settings, refer to `minify-html's \u003chttps://github.com/wilsonzlin/minify-html/blob/master/python/src/lib.template.rs/\u003e`_ source code.\n\n\nThe bindings are ( by default set to True ):\n\n.. code-block:: python\n\n      STRIP_WHITESPACE_RUST_DO_NOT_MINIFY_DOCTYPE, # passes do_not_minify_doctype to minify-html\n      STRIP_WHITESPACE_RUST_ENSURE_SPEC_CONPLIANT_UNQUOTED_ATTRIBUTE_VALUES, # passes ensure_spec_compliant_unquoted_attribute_values to minify-html\n      STRIP_WHITESPACE_RUST_KEEP_CLOSING_TAGS, # passes keep_closing_tags to minify-html\n      STRIP_WHITESPACE_RUST_KEEP_COMMENTS, # passes keep_comments to minify-html\n      STRIP_WHITESPACE_RUST_KEEP_HTML_AND_HEAD_OPENING_TAGS, # passes keep_html_and_head_opening_tags to minify-html\n      STRIP_WHITESPACE_RUST_KEEP_SPACES_BETWEEN_ATTRIBUTES, # passes keep_spaces_between_attributes to minify-html\n      STRIP_WHITESPACE_RUST_MINIFY_CSS, # passes minify_css to minify-html\n      STRIP_WHITESPACE_RUST_MINIFY_JS, # passes minify_js to minify-html\n      STRIP_WHITESPACE_RUST_REMOVE_BANGS, # passes remove_bangs to minify-html\n      STRIP_WHITESPACE_RUST_REMOVE_PROCESSING_INSTRUCTIONS, # passes remove_processing_instructions to minify-html\n\nIf you would like to change any of the above variables, simply put them in STRIP_WHITESPACE_CONFIG ( Please note that every variable here is a python boolean ).\n\nFor example:\n\n.. code-block:: python\n         \n        STRIP_WHITESPACE_CONFIG['STRIP_WHITESPACE_RUST_DO_NOT_MINIFY_DOCTYPE'] = False\n\nPython :\n~~~~~~~~\n\nThe module allows python minifier options to be changed from Flasks's environ variables. If you would like to change any settings, refer to `python-module's \u003chttps://github.com/juancarlospaco/css-html-js-minify/blob/master/css_html_js_minify/html_minifier.py/\u003e`_ source code.\n\nThe bindings are ( by default set to a sane value ):\n\n.. code-block:: python\n\n        STRIP_WHITESPACE_PYTHON_REMOVE_COMMENTS, # False | removes comments from HTML using python ( not recommended cause rust can do that just fine and fast )\n        STRIP_WHITESPACE_PYTHON_CONDENSE_STYLE_FROM_HTML, # True | replaces '\u003cstyle text/css\u003e' -\u003e '\u003cstyle\u003e'\n        STRIP_WHITESPACE_PYTHON_CONDENSE_SCRIPT_FROM_HTML, # True | replaces '\u003cscript text/javascript\u003e' -\u003e '\u003cscript\u003e'\n        STRIP_WHITESPACE_PYTHON_CLEAN_UNNEEDED_HTML_TAGS, # True | removes some unnecessary tags\n        STRIP_WHITESPACE_PYTHON_CONDENSE_HTML_WHITESPACE, # True | This is where the magic happens.\n        STRIP_WHITESPACE_PYTHON_UNQUOTE_HTML_ATTRIBUTES, # True | This is also a magic module.\n       \n\nIf you would like to change any of the above variables, simply put them in STRIP_WHITESPACE_CONFIG ( Please note that every variable here is a python boolean )\n\nFor example:\n\n.. code-block:: python\n\n        STRIP_WHITESPACE_CONFIG['STRIP_WHITESPACE_PYTHON_REMOVE_COMMENTS'] = True\n\nChange Ignored Paths :\n----------------------\n\nThis module allows dynamic ignored path allocation.\nSo for example if your sitemap.xml is at url '/sitemap.xml' and you want to avoid minifying it ( Because this module in lower level is meant to minify HTML not XML ).\nThen you can add it to ignored path. ( By default it ignores '/sitemap.xml' ) \n\nTo customize ignored path:\n\n.. code-block:: python\n        \n\n        STRIP_WHITESPACE_CONFIG['STRIP_WHITESPACE_MINIFY_IGNORED_PATHS'].append(\"/robots.txt\") # Note that STRIP_WHITESPACE_MINIFY_IGNORED_PATHS is a Python List\n\nChange NBSP Mangle Character :\n------------------------------\n\nThis module first replaces the \u0026nbsp; character from html with a character. \nFor example \u0026nbsp; becomes 'অ' ( I picked 'অ' because its a foreign character and not many sites use the character like this 'অ' ).\nIf for some reason this character is causing problem in your HTML. You can change this from STRIP_WHITESPACE_CONFIG .\n\nTo change \u0026nbsp; mangle character:\n\n.. code-block:: python\n\n\n        # Keep the string as  short as possible.\n        # If you make it long,\n        # the python str.replace() method will use more CPU and RAM thus slowing your site down.\n        \n        STRIP_WHITESPACE_CONFIG[\"STRIP_WHITESPACE_NBSP_MANGLE_CHARACTER\"] = 'ga' # Note that STRIP_WHITESPACE_NBSP_MANGLE_CHARACTER is a python string\n\nChange Compression Settings :\n-----------------------------\nThis module can do the work of compressing response to gzip. ( It can also do brotli, zstd 👀 )\n\nTo change the compression algorithm ( by default using 'gzip' because it's a python stdlib): \n   \n.. code-block:: python\n      \n      # envrion\n\n      STRIP_WHITESPACE_CONFIG[\"STRIP_WHITESPACE_COMPRESSION_ALGORITHM\"] = \"gzip\" or \"br\" or \"zstd\" or \"plain\"\n      \n\nContributing :\n==============\nIf you like this project add a star. \nIf you have problems or suggestions please put them in the `Issue Tracker \u003chttps://github.com/baseplate-admin/flask_strip_whitespace/issues\u003e`__.\nIf you like to add features. Fork this repo and submit a Pull Request. 😛\n\nUpdates ?? :\n============\nThis repository is freezed. It will automatically install latest `python-strip-whitespace \u003chttps://github.com/baseplate-admin/python_strip_whitespace\u003e`_\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaseplate-admin%2Fflask_strip_whitespace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbaseplate-admin%2Fflask_strip_whitespace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaseplate-admin%2Fflask_strip_whitespace/lists"}