Python CSS/Javascript minifier

Related tags

DjangoSqueezeit
Overview

Squeezeit - Python CSS and Javascript minifier Copyright (C) 2011 Sam Rudge

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

#WTF? Squeezeit is a small Python utility to scratch my own personal itch. It attempts to provide a lot of the features of the Rails asset pipeline with regards to combining and minifying bundles of Javascript and CSS files, pre-compressing .gz versions of files and simplifying management of site media.

#Make shit happen Download, setup.py install and run squeezeit /path/to/config.yaml (see below)

#Configuration Squeezeit is configured through the use of YAML files. There are two types of YAML file needed for squeezeit to run;

##Main config.yaml Specifies the main configuration options for the bundler, such as source directories and output directories.

#Main bundle config
#All paths are relative to this file

#Logging level (Standard Python logging levels: DEBUG, INFO, WARNING or CRITICAL)
logging: INFO

#Specify the directory for bundle YAML files (The files that specify your bundles and their contents)
bundles: ./config/

#Where to output the bundles and bundle info file
output: ./bundles/

#Source files
css: ./css/
javascript: ./js/

#Bundle names include MD5 hash of contents (E.G. [bundlename]-[md5 hash].js - See bundle info file)
hashfilenames: true

##Bundle configuration files These are YAML files in the 'bundles' directory specified above. A bundle config file contains all the media that should be included with a particular bundle. Output bundles will be named the same as the YAML file (so media.yaml will output media.js, media.css etc.)

#Paths are relative to the 'source file' directories specified in the main config file
includes:
    css:
        - clear.css
        - fonts.css
        - bootstrap.css
		- main.css
    javascript:
        - jquery/core.js #Oh, you can use sub-folders too
        - main.js

All bundles will output 6 (or 3) files;

  • bundlename.js/css - Combined but not minified files, this is the same as cat file1.js file2.js >> bundle.js
  • bundlename.min.js/css - Combined and minified versions of the files. JS minification is done using JSMin and CSS minification is done using slimmer
  • bundlename.min.js/css.gz - Combined, minified and GZipped version of the file.

You don't have to include both javascript and CSS in a bundle, just leave the array blank in the bundle config file

##Bundle info file The bundler outputs a 'bundle info file' to output-directory/info.yaml. The bundle info file contains information about the sizes of the bundles, and their MD5 has (useful for using MD5 in filenames).

media:
	css:
		md5: 3c716f5993efd3257fe17b219c6b6ecd #MD5 is generated from the combined data, before it's minified
		output: {
			gz: media-3c716f5993efd3257fe17b219c6b6ecd.min.css.gz,
			min: media-3c716f5993efd3257fe17b219c6b6ecd.min.css,
			raw: media-3c716f5993efd3257fe17b219c6b6ecd.css
		}
		size: {
			gz: 328,
			min: 704,
			raw: 821
		}
	javascript:
		md5: 9581d699b54badf07d4e1f60f77dca7d
		output: {
			gz: media-9581d699b54badf07d4e1f60f77dca7d.min.js.gz,
			min: media-9581d699b54badf07d4e1f60f77dca7d.min.js,
			raw: media-9581d699b54badf07d4e1f60f77dca7d.js
		}
		size: {
			gz: 33142,
			min: 93837,
			raw: 93939
		}

If ether Javascript or CSS source files are not specified in the bundle, the value of 'md5' will be set to false (md5: false) so you can detect that from your code.

#It wasn't all me

Squeezeit includes two excellent libraries to do it's work (on top of the standard Python ones);

  • JSMin.py - By Douglas Crockford and Dave St.Germain
  • Slimmer - By Peter Bengtsson

Other cool things to check out;

  • PNGCrush - Great at optimising images and stuff
Owner
Smudge
Coding dog thing. I make servers do stuff, not always the stuff they want to do.
Smudge
Create a netflix-like service using Django, React.js, & More.

Create a netflix-like service using Django. Learn advanced Django techniques to achieve amazing results like never before.

Coding For Entrepreneurs 67 Dec 08, 2022
django-dashing is a customisable, modular dashboard application framework for Django to visualize interesting data about your project. Inspired in the dashboard framework Dashing

django-dashing django-dashing is a customisable, modular dashboard application framework for Django to visualize interesting data about your project.

talPor Solutions 703 Dec 22, 2022
Atualizando o projeto APIs REST Django REST 2.0

APIs REST Django REST 3.0-KevinSoffa Atualização do projeto APIs REST Django REST 2.0-Kevin Soffa Melhorando e adicionando funcionalidades O que já fo

Kevin Soffa 2 Dec 13, 2022
Highlight the keywords of a page if a visitor is coming from a search engine.

Django-SEKH Django Search Engine Keywords Highlighter, is a middleware for Django providing the capacities to highlight the user's search keywords if

Julien Fache 24 Oct 08, 2021
Django API creation with signed requests utilizing forms for validation.

django-formapi Create JSON API:s with HMAC authentication and Django form-validation. Version compatibility See Travis-CI page for actual test results

5 Monkeys 34 Apr 04, 2022
Updates redisearch instance with igdb data used for kimosabe

igdb-pdt Update RediSearch with IGDB games data in the following Format: { "game_slug": { "name": "game_name", "cover": "igdb_coverart_url",

6rotoms 0 Jul 30, 2021
This is a repository for collecting global custom management extensions for the Django Framework.

Django Extensions Django Extensions is a collection of custom extensions for the Django Framework. Getting Started The easiest way to figure out what

Django Extensions 6k Dec 26, 2022
Developer-friendly asynchrony for Django

Django Channels Channels augments Django to bring WebSocket, long-poll HTTP, task offloading and other async support to your code, using familiar Djan

Django 5.5k Dec 29, 2022
Django StatusPage - App to display statuspage for your services

Django StatusPage - App to display statuspage for your services

Gorlik 1 Oct 27, 2021
DRF_commands is a Django package that helps you to create django rest framework endpoints faster using manage.py.

DRF_commands is a Django package that helps you to create django rest framework endpoints faster using manage.py.

Mokrani Yacine 2 Sep 28, 2022
A Powerful HTML white space remover for Django

HTML Whitespace remover for Django Introduction : A powerful tool to optimize Django rendered templates Why use "django_stip_whitespace" ? Adds line b

3 Jan 01, 2022
Twitter Bootstrap for Django Form - A simple Django template tag to work with Bootstrap

Twitter Bootstrap for Django Form - A simple Django template tag to work with Bootstrap

tzangms 557 Oct 19, 2022
Djangoblog - A blogging platform built on Django and Python.

djangoblog 👨‍💻 A blogging platform built on Django and Python

Lewis Gentle 1 Jan 10, 2022
this is a simple backend for instagram with python and django

simple_instagram_backend this is a simple backend for instagram with python and django it has simple realations and api in 4 diffrent apps: 1-users: a

2 Oct 20, 2021
A simple E-commerce shop made with Django and Bulma

Interiorshop A Simple E-Commerce app made with Django Instructions Make sure you have python installed Step 1. Open a terminal Step 2. Paste the given

Aditya Priyadarshi 3 Sep 03, 2022
Django React Flight Rezervation

Django Intro & Installation python -m venv venv source ./venv/Scripts/activate pip install Django pip install djangorestframework pip install python-d

HILMI SARIOGLU 2 May 26, 2022
Template for Django Project Using Docker

You want a Django project who use Docker and Docker-compose for Development and for Production ? It's for you !

1 Dec 17, 2021
Dynamic, database-driven Django forms

Django Dataforms django-dataforms is a wrapper for the Django forms API that lets you dynamically define forms in a database, rather than hard-coding

35 Dec 16, 2022
Getdp-project - A Django-built web app that generates a personalized banner of events to come

getdp-project https://get-my-dp.herokuapp.com/ A Django-built web app that gener

CODE 4 Aug 01, 2022
scaffold django rest apis like a champion 🚀

dr_scaffold Scaffold django rest apis like a champion ⚡ . said no one before Overview This library will help you to scaffold full Restful API Resource

Abdenasser Elidrissi 133 Jan 05, 2023