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
Automated image processing for Django. Currently v4.0

ImageKit is a Django app for processing images. Need a thumbnail? A black-and-white version of a user-uploaded image? ImageKit will make them for you.

Matthew Dapena-Tretter 2.1k Jan 04, 2023
ProjectManagementWebsite - Project management website for CMSC495 built using the Django stack

ProjectManagementWebsite A minimal project management website for CMSC495 built

Justin 1 May 23, 2022
A GitHub Action for checking Django migrations

🔍 Django migrations checker A GitHub Action for checking Django migrations About This repository contains a Github Action that checks Django migratio

Oda 5 Nov 15, 2022
a little task queue for python

a lightweight alternative. huey is: a task queue (2019-04-01: version 2.0 released) written in python (2.7+, 3.4+) clean and simple API redis, sqlite,

Charles Leifer 4.3k Dec 29, 2022
Notes-Django: an advanced project to save notes in Django. where users are able to Create, Read, Update and Delete their notes.

An advanced software to keep you notes. It allows users to perform CRUD operations on theirs Notes. Was implemented Authorization and Authentication

Edilson Pateguana 1 Feb 05, 2022
Book search Django web project that uses requests python library and openlibrary API.

Book Search API Developer: Vladimir Vojtenko Book search Django web project that uses requests python library and openlibrary API. #requests #openlibr

1 Dec 08, 2021
An automatic django's update checker and MS teams notifier

Django Update Checker This is small script for checking any new updates/bugfixes/security fixes released in django News & Events and sending correspon

prinzpiuz 4 Sep 26, 2022
Faker is a Python package that generates fake data for you.

Faker is a Python package that generates fake data for you. Whether you need to bootstrap your database, create good-looking XML documents, fill-in yo

Daniele Faraglia 15.2k Jan 01, 2023
It takes time to start a Django Project and make it almost production-ready.

It takes time to start a Django Project and make it almost production-ready. A developer needs to spend a lot of time installing required libraries, setup a database, setup cache as well as hiding se

Khan Asfi Reza 1 Jan 01, 2022
Source files for a free pyRevit toolbar.

pyRoovit (WIP) What is this? PyRoovit is/will be a toolbar for the use with pyRevit built by Gavin Crump (aka Aussie BIM Guru). Having used and taught

Gavin Crump 11 Nov 10, 2022
Packs a bunch of smaller CSS files together from 1 folder.

Packs a bunch of smaller CSS files together from 1 folder.

1 Dec 09, 2021
A pluggable Django application for integrating PayPal Payments Standard or Payments Pro

Django PayPal Django PayPal is a pluggable application that integrates with PayPal Payments Standard and Payments Pro. See https://django-paypal.readt

Luke Plant 672 Dec 22, 2022
mirage ~ ♪ extended django admin or manage.py command.

mirage ~ ♪ extended django admin or manage.py command. ⬇️ Installation Installing Mirage with Pipenv is recommended. pipenv install -d mirage-django-l

Shota Shimazu 6 Feb 14, 2022
A music recommendation REST API which makes a machine learning algorithm work with the Django REST Framework

music-recommender-rest-api A music recommendation REST API which makes a machine learning algorithm work with the Django REST Framework How it works T

The Reaper 1 Sep 28, 2021
Simple web site for sharing your short stories and beautiful pictures

Story Contest Simple web site for sharing your short stories and beautiful pictures.(Cloud computing first assignment) Clouds The table below shows cl

Alireza Akhoundi 5 Jan 04, 2023
An API was build with Django to store and retrieve information about various musical instruments.

The project is meant to be a starting point, an experimentation or a basic example of a way to develop an API with Django. It is an exercise on using Django and various python technologies and design

Kostas Ziovas 2 Dec 25, 2021
Opinionated boilerplate for starting a Django project together with React front-end library and TailwindCSS CSS framework.

Opinionated boilerplate for starting a Django project together with React front-end library and TailwindCSS CSS framework.

João Vítor Carli 10 Jan 08, 2023
A reusable Django model field for storing ad-hoc JSON data

jsonfield jsonfield is a reusable model field that allows you to store validated JSON, automatically handling serialization to and from the database.

Ryan P Kilby 1.1k Jan 03, 2023
Use Database URLs in your Django Application.

DJ-Database-URL This simple Django utility allows you to utilize the 12factor inspired DATABASE_URL environment variable to configure your Django appl

Jacob Kaplan-Moss 1.3k Dec 30, 2022
A simple demonstration of integrating a sentiment analysis tool in a django project

sentiment-analysis A simple demonstration of integrating a sentiment analysis tool in a django project (watch the video .mp4) To run this project : pi

2 Oct 16, 2021