Permalink
Browse files

more documentation with an example

  • Loading branch information...
1 parent e2d9bbb commit 074ece7cca5bf440927d5be789ec6db57f586781 @peterbe committed Jan 14, 2013
Showing with 108 additions and 2 deletions.
  1. +1 −0 .gitignore
  2. +30 −1 README.md
  3. +1 −1 docs/index.rst
  4. +7 −0 example/page.css
  5. +28 −0 example/page.html
  6. +38 −0 example/run_mincss
  7. +3 −0 example/run_server
View
@@ -3,3 +3,4 @@ proxy/.cache/
docs/_build/
mincss.egg-info/
/build/
+/dist/
View
@@ -1,7 +1,8 @@
mincss
======
-Tool for finding out which CSS selectors you're NOT using.
+Clears the junk out of your CSS but finding out which selectors are
+actually not used in your HTML.
By Peter Bengtsson, 2012-2013
@@ -19,3 +20,31 @@ using.
This tool can help you get started reducing all those selectors that
you're not using.
+
+Whitespace compression?
+-----------------------
+
+No, that's a separate concern. This tool works indendent of
+whitespace compression/optimization.
+
+For example, if you have a build step or a runtime step that converts
+all your CSS files into one (concatenation) and trims away all the
+excess whitespace (compression) then the output CSS can still contain
+selectors that are never actually used.
+
+What about AJAX?
+----------------
+
+If you have a script that creates DOM elements in some sort of
+``window.onload`` event then ``mincss`` will not be able to know this
+because at the moment ``mincss`` is entirely static.
+
+So what is a web developer to do? Simple, use ``/* no mincss */`` like
+this for example:
+
+ .logged-in-info {
+ /* no mincss */
+ color: pink;
+ }
+
+That tells ``mincss`` to ignore the whole block and all its selectors.
View
@@ -3,7 +3,7 @@
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
-mincss - clears the junk out of your CSS
+mincss - Clears the junk out of your CSS
========================================
``mincss`` is a Python library that makes it possible to evaluate
View
@@ -0,0 +1,7 @@
+#content p, #content blockquote {
+ font-family: Arial;
+}
+
+@media (min-width: 1200px) {
+ p, li, blockquote { font-size: 1.5em; }
+}
View
@@ -0,0 +1,28 @@
+<!doctype html>
+<html>
+ <head>
+ <title>Example page</title>
+ <link rel="stylesheet" href="page.css">
+ <style type="text/css">
+ .foo, .othercrap { color: blue; }
+ .bar { color: green; /* no mincss */}
+ </style>
+
+ </head>
+ <body>
+ <div id="content">
+ <p class="foo">Expect this to be blue</p>
+ </div>
+
+ <script>
+ onload = function() {
+ var parent = document.getElementById('content');
+ var bar = document.createElement('p');
+ bar.className = 'bar';
+ var text = document.createTextNode('Expect this to be green');
+ bar.appendChild(text);
+ parent.appendChild(bar);
+ };
+ </script>
+ </body>
+</html>
View
@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+
+from mincss.processor import Processor
+
+
+URL = 'http://localhost:9000/page.html'
+
+def run():
+ p = Processor()
+ p.process(URL)
+
+ print "INLINES ".ljust(79, '-')
+ for each in p.inlines:
+ print ("On line %s" % each.line)
+ print '- ' * 40
+ print "BEFORE"
+ print each.before
+ print '- ' * 40
+ print "AFTER:"
+ print each.after
+ print
+ print
+
+ print "LINKS ".ljust(79, '-')
+ for each in p.links:
+ print ("On href %s" % each.href)
+ print '- ' * 40
+ print "BEFORE"
+ print each.before
+ print '- ' * 40
+ print "AFTER:"
+ print each.after
+ print
+ print
+
+
+if __name__ == '__main__':
+ run()
View
@@ -0,0 +1,3 @@
+#!/bin/bash
+echo "After this is started, run './run_mincss' from this same directory"
+python -m SimpleHTTPServer 9000

0 comments on commit 074ece7

Please sign in to comment.