(function($){
"use strict";
$(document).ready(function(){
/*
01. Remove comments /\/\*(?:(?!\*\/)[\s\S])*\*\/|[\r\n\t]+/gi
old: /\/\*([\s\S]*?)\*\//gi
02. Remove space and return characters before and after comma /(\,)\r?(\s)*?(?=[\w\*])/gi replace with "$1"
03. Remove space between selector and opening curly brace /([\w\d\]\)\*])\s*?(?={)/gi replace with "$1"
04. Remove space between opening curly brace and property /({)([\s\S]*?)(?=(\w|\-|\.|\#|\*|\@|\[|\/))/gi replace with "$1"
05. Remove space between property and colon, also space between col /\s*?\:\s*?(?=[\w\.\#])/gi Replace with :
06. Remove space between semicolon and property /(\;)([\s\S])*?(?=[\d\w\-\}\*\@])/gi replace with "$1"
08. Remove space between closing curly brace and selector /(\})([\s])*?(?=[\w\@\[\.\#\*\}])/gi replace with "$1"
09. Remove last semicolon /\;([\s])*?(?=})/gi
10. Replace 0px with 0 /(\s)0px/gi replace with "$10"
12. Optimize color values /#[0-9a-f]{6,8}/gi
*/
$('#crunch').on('click', function(){
var cssInput = $('#css-input').val(),
rmComments = /\/\*(?:(?!\*\/)[\s\S])*\*\/|[\r\n\t]+/gi,
rmSpReBeAfComma = /(\,)\r?(\s)*?(?=[\w\*\.\#])/gi,
rmSpSelctorOpenCurly= /([\w\d\]\)\*])\s*?(?={)/gi,
rmSpOpenCurlySel= /({)([\s\S]*?)(?=(\w|\-|\.|\#|\*|\@|\[|\/))/gi,
rmSpBeAfColon= /\s*?\:\s*?(?=[\w\.\#])/gi,
rmSpSemiColonProp= /(\;)([\s\S])*?(?=[\d\w\-\}\*\@])/gi,
rmSpClosingCurlySel = /(\})([\s])*?(?=[\w\@\[\.\#\*\}])/gi,
rmLstSemi = /\;([\s])*?(?=})/gi,
replacePxWithZero = /(\s)0px/gi,
colorHex = /#[0-9a-f]{6,8}/gi,
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.