Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mincss
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
mincss
Commits
a922ebfd
Commit
a922ebfd
authored
Jul 28, 2014
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Documentation
parent
f143b684
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
41 deletions
+22
-41
README.md
README.md
+22
-41
No files found.
README.md
View file @
a922ebfd
...
...
@@ -61,47 +61,28 @@ Compression phases
==================
To achieve the features listed above, the input stylesheet is rewritten in a
number of
phase
s:
number of
step
s:
1.
`parse`
: Transform the input into an Abstract Syntax Tree (AST) in
accordance with the CSS syntax definition. This eliminates unnecessary
whitespaces and catches syntax errors.
2.
`unfold`
:
-
Transform shorthand declarations into a separate declaration for each
1.
Parse the input CSS, producing an Abstract Syntax Tree (AST) in accordance
with the CSS syntax definition. This eliminates unnecessary whitespaces and
catches syntax errors.
2.
Transform shorthand declarations into a separate declaration for each
expression in the shorthand.
-
Duplicate rulesets for each of its selectors, so that every ruleset has
3.
Duplicate rulesets for each of its selectors, so that every ruleset has
exactly one block of declarations.
3.
`concat`
: Concatenate different declaration blocks for the same selector.
Now, every selector has exacly one block of declarations associated with it.
4.
`optimize`
: Optimize individual declaration blocks by generating shorthand
declarations and simple compression on expressions (color compression,
removal of unnecessary string quotes, etc.).
5.
`combine`
: Try to combine declarations for different selectors, by comparing
each pair of rulesets and checking if a shorter representation is possible
by generating a shared ruleset.
Motivation
----------
The use of a proper CSS syntax definition for the parser, rather than a simple
ad-hoc tokenizer, assures that all unnecessary whitespace is ignored. The AST
definition also provides a convenient infrastructure for the subsequent
transformations.
The unfolding phase eliminates any clever constructions used by the programmer,
so that the following phases can make assumptions about the format of the
stylesheet and need not deal with, for example, shorthand declarations.
Concatenation of declaration blocks for the same selector is necessary in order
to generate a single minimal representation for each selector in the
`optimize`
phase.
The
`combine`
phase is tricky to implement, since it is difficult to prove if
the resulting combinations are in fact the shortest possible representation of
the stylesheet. If this is not the case, the risk exists that while the
programmer efficiently merged some declarations for different selectors, the
compressor unfolds the ruleset and generates somethning longer.
*FIXME*
: how do we solve this?
4.
Create a new declaration block for each property declaration on each
selector, e.g.
`a,p{color:red;border:blue}`
becomes
`a{color:red}
a{border:blue} p{color:red} p{border:blue}`
.
5.
Prune duplicate declarations (when the same property is overwritten for the
same selector). Note: this may be disabled with
`--no-prune`
for stylesheets
that contain duplication hacks.
6.
Combine selectors for identical blocks (as long as the correct order of
declarations is preserved).
7.
Concatenate blocks for identical (combinations of) selectors.
8.
Optimize individual declaration blocks by generating shorthand declarations
and simple compression on expressions (i.e. color compression, removal of
unnecessary string quotes, etc.).
9.
Output the resulting AST with minimal whitespace.
Building mincss
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment