Overview
Explore the intricacies of building a CSS minifier in this 40-minute conference talk from GOTO Aarhus 2014. Delve into the world of CSS post-processing with Stoyan Stefanov, Facebook engineer and author of "JavaScript Patterns." Learn about the challenges of parsing CSS, current available parsers, and the introduction of cssshrink.com, a modern open-source CSS minifier. Discover techniques for parsing, understanding, and reducing CSS code, as well as writing code that is more compression-friendly. Cover topics ranging from key-value parsing to full AST parsing, delivering browser-specific stylesheets, and creating pre/post-processors for missing or proposed CSS features. Gain insights into various optimization techniques, including handling spaces and comments, color optimization, number formatting, quote management, pseudo-element handling, and dealing with duplicates in declarations, selectors, and keyframes.
Syllabus
Introduction
Agenda
Motivation
CSS is hard
Crockford on CSS
Solution
Partial parsing
How about
Next: write a parser
Next: use a parser
Space, comments
Colors
Zeros, numbers
Quotes
Pseudo
font-weight
Lowercase
Duplicate declarations
Duplicate selectors
Adjacent selectors
Adjacent blocks
Random nonsense
Shorthands
Unit conversions
Duplicate keyframes
Rename
Supporting tools
Taught by
GOTO Conferences