GitHub - nate-parrott/m.py: Takes an HTML document, minifies and inlines all CSS and JS. Includes WSGI middleware for platforms like Google AppEngine, and optional memcached caching.

1 min read Original article ↗

m.py

Takes an HTML document, minifies and inlines all CSS and JS. Includes WSGI middleware for platforms like Google AppEngine, and optional memcached caching.

Installation

Add m.py to your project, as well as all the dependencies;

  • cssutils
  • htmlmin
  • slimit (JS minifier)
  • BeautifulSoup4

Usage

from m import minify
minified_html = minify(html)

On AppEngine:

Replace:

app = webapp2.WSGIApplication([
    ('/', MainHandler),
])

with:

app = webapp2.WSGIApplication([
    ('/', MainHandler),
])
import m
app = m.WSGIMiddleware(app, memcache=memcache)