1
1
![ Logo] ( css-ratiocinator/raw/master/illustration/githubheader.png " Logo ")
2
2
3
3
The CSS Ratiocinator automatically refactors your CSS and generates a
4
- new stylesheet for your site. It works by examining your site's live
5
- DOM in the browser and reverse engineering a new, more elegant, CSS
6
- definition that captures styles down to the pixel.
4
+ new stylesheet for your site. It works by examining your site's live DOM
5
+ in the browser and reverse engineering a new, more elegant definition
6
+ that captures styles down to the pixel.
7
7
8
8
It addresses the problem of old CSS whose styles accumulate and
9
9
contradict each other. After a certain point all CSS seems to grow only
10
- by internal antagonism. The ratiocinator wipes the slate clean and
10
+ by internal antagonism. The Ratiocinator wipes the slate clean and
11
11
provides a harmonious new beginning.
12
12
13
13
## Usage
@@ -24,3 +24,33 @@ Runs best in [Google Chrome](//www.google.com/chrome).
24
24
25
25
## Mechanism
26
26
27
+ The ratiocinator proceeds in two phases: assessment and consolidation.
28
+ During assessment it determines which nodes will need which styles,
29
+ accounting for browser defaults and cascade rules. The browser provides
30
+ a full list of computed style for every node, and our first step is to
31
+ prune redundencies from cascaded style in a depth-first process called
32
+ "lifting." ![ Lifting] ( css-ratiocinator/raw/master/illustration/lift.png " Lifting ")
33
+
34
+ The last step in assessment is stripping default styles. The final
35
+ style needn't specify CSS defaults, so we remove them prior to the
36
+ consolidation phase.
37
+
38
+ Next comes consolidation, where we find shared pieces of style
39
+ throughout the cleaned DOM tree and extract them to CSS declarations.
40
+
41
+ ![ Consolidating] ( css-ratiocinator/raw/master/illustration/consolidate.png " Consolidating ")
42
+
43
+ In the diagram above, the ratiocinator will choose to output a
44
+ declaration for the styles in red before those in blue. Although there
45
+ are more blue items than red in element ` aside.foo ` , there are more red
46
+ elements overall. The red has greater "volume." Hence the ratiocinator
47
+ will extract styles for all elements with class ` foo ` first and then for
48
+ ` aside ` elements second.
49
+
50
+ ## Contributing
51
+
52
+ ## License
53
+
54
+ The CSS Ratiocinator is Copyright © 2012 Joe Nelson. It is free
55
+ software, and may be redistributed under the terms specified in the
56
+ LICENSE file.
0 commit comments