About tgext.minify
tgext.minify is a Turbogears 2 middleware that automatically minifies your javascript and CSS and cache it. It’s able to obfuscate your js too. CSS minifier based on rCSSmin by André Malo. JS minifier/obfuscator based on SlimIt by Ruslan Spivak The middleware is based on tgext.scss by Alessandro Molina
Installing
tgext.scss can be installed both from pypi or from bitbucket:
easy_install tgext.minify
should just work for most of the users
Enabling tgext.minify
If tgext.pluggable is available enabling tgext.minify is just a matter of appending to your config/app_cfg.py:
from tgext.pluggable import plug plug(base_config, 'tgext.minify')
Otherwise manually using tgext.minify is really simple, you edit your config/middeware.py and just after the #Wrap your base TurboGears 2 application with custom middleware here comment wrap app with MinifyMiddleware:
from tgext.minify import MinifyMiddleware
make_base_app = base_config.setup_tg_wsgi_app(load_environment)
def make_app(global_conf, full_stack=True, **app_conf):
app = make_base_app(global_conf, full_stack=True, **app_conf)
# Wrap your base TurboGears 2 application with custom middleware here
app = MinifyMiddleware(app)
return app
Now you just have to put your beautiful .css and .js files inside public/ and they will be served as minified.
JS obfuscation
If you need to obfuscate your javascript, just add mangle_js = true to your development.ini. If you want to obfuscate also the global scope, add mangle_js_toplevel = true. Keep in mind that if you obfuscate your js, you have to join js files that depends on each other, or the namespace will be messed up.
Performance boost
Here is the report of a benchmark made on paster serving bootstrap.css with and without the middleware and then bootstrap.min.js already minified (without using the middleware):
$ /usr/sbin/ab -n 1000 http://localhost:8080/css/bootstrap.css Requests per second: 1135.50 [#/sec] (mean) $ /usr/sbin/ab -n 1000 http://localhost:8080/css/bootstrap.css Requests per second: 714.99 [#/sec] (mean) $ /usr/sbin/ab -n 1000 http://localhost:8080/css/bootstrap.min.css Requests per second: 806.26 [#/sec] (mean)
In these case serving the unminified css using tgext.minify is even faster than directly serving the same css file as it is served from memory (due to caching performed by tgext.minify).
Metadata
Release files for tgext.minify 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tgext.minify-0.0.2.tar.gz | 7.4 kB | Without provenance | Details for tgext.minify-0.0.2.tar.gz |
Release files / tgext.minify-0.0.2.tar.gz
| Download URL | tgext.minify-0.0.2.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9093517e0f9cd79fdd382694459f8b778991598f1cbb3e168937fbbb7d4cbf70
|
|
BLAKE2b-256 checksum How to use checksums |
5d1d25457df1b0f2fcdc54e5bba346c073a0fd728ea9ad33d409d143e94abc19
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for tgext.minify 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.