htmlcompressor

Compress HTML CSS and Java Script of a page.


Keywords
html
License
GPL-3.0
Install
pip install htmlcompressor==1.0.1

Documentation

htmlcompressor

https://travis-ci.org/sxslex/htmlcompressor.svg?branch=master

Compress HTML CSS and Java Script of a page. Passes all original unittests.

Usage

>>> import htmlcompressor
>>> htmlcompressor.compress('''
...<html>
...    <head>
...        <title>  Test  </title>
...        <script type="text/javascript">  alert(1)  </script>
...        <script type="text/javascript">  alert(2);  </script>
...    </head>
...     <body>
...         <style type="text/css">  .class {   display:  none; } </style>
...     </body>
...</html>
... ''')
'<html><head><title>Test</title><script>alert(1);alert(2)</script></head><body><style>.class{display:none}</style></body></html>'
>>> import htmlcompressor
>>> @htmlcompressor.decorator()
>>> def index():
>>>     return '''
...<html>
...    <head>
...        <title>  Test  </title>
...        <script type="text/javascript">  alert(1)  </script>
...        <script type="text/javascript">  alert(2);  </script>
...    </head>
...     <body>
...         <style type="text/css">  .class {   display:  none; } </style>
...     </body>
...</html>
... '''
'<html><head><title>Test</title><script>alert(1);alert(2)</script></head><body><style>.class{display:none}</style></body></html>'

Installation

Use pip or easy_install:

$ pip install git+https://github.com/sxslex/htmlcompressor.git

Development

Use py.test to run unittests