Open Letter to Web Designers and Developers: Max CSS
daneden.me
daneden.me
Creating CSS which matches your design should not really be an issue, and as others have pointed out, if you see something on another website that you like, then you can just use chrome inspector which would always work by an order of magnitude better than using a main.max.css sheet as you suggest.
I'm not going to be elitist and say that learning CSS is a non-issue, but maintaining a commented CSS would be ridiculous. Especially when all of my CSS is automatically compliled (lessCSS) and comments are stripped.
What would your main.max.css look like?
.container {
border: 1px solid black; // This adds a solid black border
float: left; // Remove element from doc flow, and align left
padding: 10px; // This adds a 10px padding
background: white; // This sets the background white
}
When I read the title of this post, I thought that you might of been suggesting that developers maintain two sheets, a[1] main.min.css
[2] main.max.css
Inside of the min CSS, you might use all of your layouting styles and lightweight background styles. However, inside of the max you would add all of your complementary styles.
Such as all of the background gradients. All of your vendor specific box shadows, border-radius', box-sizing, opacitys, etc. Getting background gradients compatible accross different browser vendors totally bloats my CSS (by about a 100-140kb (since I use alot of high quality gradients instead of png).
I could perhaps get behind the idea to seperate two sheets. One min.css for pure templating and layout, and a max.css for all that awesomeness.
The only benefit this would give is being able to detect a user agent and serve up the more lightweight version.
Anyway, big NO NO, for your suggestion. I can't get behind that idea.
def foo(): # This defines a function
a = 5 # This defines a variable, a = 5
return a + 5 # The function returns the value of a + 5
Not to argue in favor of or against max.css, but nobody comments their code like that. It's more about things like this: .ribbon-edge {
/**
* By setting the width and height to 0
* and having a really large border, we
* can use the way the borders intersect
* to create a ribbon edge for our header/
* This results in three angled red borders,
* and one transparent, right-facing triangle
* on the left side.
*/
width: 0;
height: 0;
border: 50px solid transparent;
border-left-color: red;
}1) Fully think through what they are doing (clearly they are experts)
2) Comment their code, regardless of where it is in the stack
Generally, when I comment code, I dont do things like "this adds a solid black border". Ya-don't-fucking-say? What should be done, is comment on how this piece of code relates to the larger system at hand, how it interacts with other portions of code, or what else it relies on to work, an example of where it is used, and what not to expect from it. If developers thought this way, we would:
1) Overall have better software in this world, as it requires that the developer think through what he is writing thoroughly instead of rapid-browser iterations and "it works I'm done."
2) Help other developers in our own project, and anyone else who is trying to learn from the source without the benefit of the context the code was written in.
As time goes on I see developers getting comfortable with Ruby, Coffeescript, and the like. They don't comment at all because "the code is readable." Well, if it was readable, they wouldn't fucking call it code! All this really tells me is they don't respect their craft or anyone else who needs to interface or change that code after they've moved on.
As professionals we should take pride in our work. If engineers built bridges like we do software many many people would die and software would be illegal. Now of course development is a little different as most software crashes don't kill people (although some certainly could), but don't use that argument as a way to get comfortable and not do your job with pride.
Expecting comments in css to act as some sort of tutorial is a dead end, any website will involve html/css/js working in tandem, why put them in css, rather than html, or js?
A better format for this would be a number of good old fashioned tutorials, screencasts etc geared toward providing the mental tools to inspect any website.
So, sure it wouldn't be much work to add in a comment pointing to an unminified css file, but i fear it would be of little utility to someone learning. That is ignoring the fact i often have 20+ css files across a large site (minified compiled and combined before serving), similar number of js resources and who knows how many combinations of html templates...
That said, I usually don't minify my CSS anyway. I was just wondering if there are any significant cases where comments would make a huge difference to someone who is learning CSS.
Not sure how much though.
static/style/foo.css
containing the comment /* See static/style/foo.css.src on this domain */
since you want the source for the deployed version, not master, and we're trying to make things easy for people grokking what's deployed, not express an opinion about branch naming and deployment practices :)Publishing the repository URL and/or deployed branch/tag/revision might also be awesome, but it serves a different albeit overlapping set of goals.
I finally took the leap a few months ago, and have started out on my own app. The thing that i have found most in my journey is that there seems to be a wealth of information out there for newbies - such as the htmlcss book or the w3schools site - and a wealth of information for people at a more advanced level - though i've noticed conversation between experienced devs is what is helping them. There doesnt however, seem to be much targeted at the intermediate level of developers that kind of get wedged in between a rock and a hard place (like me).
Take git or mercurial for example. Lots of information explaining what git is, what the advantages of dvcs are. Also plenty of tips and tricks and cheat sheets for someone already using dvcs, but nothing at someone that's understood the basics but wants to go up a level.
People like me are desperately trying to get to the next level in both design and development.
So i beg all of you that are at a more advanced level and have been doing design or dev for a considerable length of time, to please think about us intermediate people; us non-designers and non-programmers that want to create something great and have finally plucked up the courage to have a go. Help us out. Please.
I'm not saying that many of us, won't still try even if you dont reach out to us. The best way to learn, of course is just to dive in and keep cracking on at it, but if you guys were to think about us, it would make our lives just that little bit easier and more rewarding.
1) Google 'git commands' and you might find something like this: http://searchco.de/lists/list-of-git-commands
2) Reading through this page, git blame might catch your eye but you can't make it from
"git blame [-c] [-b] [-l] [--root] [-t] [-f] [-n] [-s] [-p] [-w] [--incremental] [-L n,m] [-S <revs-file>] [-M] [-C] [-C] [-C] [--since=<date>] [<rev> | --contents <file> | --reverse <rev>] [--] <file>"
to a functioning command on your codebase.3) Google 'git blame tutorial' and find something like http://alblue.bandlem.com/2011/07/git-tip-of-week-assigning-...
4) A quick read through this tutorial results in non-beginner knowledge gained.
This applies to everything technical including all aspects of design and programming.
Consider the excellent MDN instead, https://developer.mozilla.org/en-US/
W3Schools is still an OK reference site. I haven't really looked at their tutorials.
That's not to say CSS comments are useless, but they should be helpful, not necessary.
zx2c4@albali ~/zx2c4.com $ cat Makefile
JS_DIR = js
CSS_DIR = css
JS_MIN = $(JS_DIR)/scripts.min.js
CSS_MIN = $(CSS_DIR)/styles.min.css
JS_MIN_FILES := $(patsubst %.js, %.min.js, $(filter-out %.min.js, $(wildcard $(JS_DIR)/*.js)))
CSS_MIN_FILES := $(patsubst %.css, %.min.css, $(filter-out %.min.css, $(wildcard $(CSS_DIR)/*.css)))
JS_COMPILER = ~/opt/bin/google-compiler --warning_level QUIET
CSS_COMPILER = ~/opt/bin/yuicompressor --type css
.PHONY: all clean
all: $(JS_MIN) $(CSS_MIN)
%.min.js: %.js
@echo "Compiling javascript" $<
@$(JS_COMPILER) --js $< --js_output_file $@
%.min.css: %.css
@echo "Compiling stylesheet" $<
@$(CSS_COMPILER) -o $@ $<
$(JS_MIN): $(JS_MIN_FILES)
@echo "Assembling compiled javascripts"
@cat $^ > $@
$(CSS_MIN): $(CSS_MIN_FILES)
@echo "Assembling compiled stylesheets"
@cat $^ > $@
clean:
@rm -fv $(JS_MIN) $(JS_MIN_FILES) $(CSS_MIN) $(CSS_MIN_FILES)
You prefix the js/css files with an order number.js/000-jquery-1.2.3.js js/001-silly-jquery-plugin.js js/002-another-silly-jquery-plugin.js js/010-something-else.js js/100-fetcher.js
or whatever kind of ordered number scheme you like. This way, the Makefile's auto-discovery of the js/.js and css/.css contents will maintain order.
https://github.com/h5bp/html5-boilerplate/issues/820
In this thread I ended up proposing something very much like what Dan is saying here but realized (after Kevin Dangoor, product manager of Firefox's Developer Tools, chimed in) that indeed source maps were designed exactly for this situation, no authoring convention or filename guessing necessary.
Source maps not only can point to the original sources, but can translate between minified css and fully formatted Sass with comments, and developer tools can identify the mapping.
As for how ready this is, CSS source map plumbing is in both Firefox and WebKit, though they are not totally complete. I believe FF has a Google Summer of Code student working on the feature: https://wiki.mozilla.org/DevTools/Features/CSSSourceMap
Just because its relevant: all the source map projects: https://github.com/ryanseddon/source-map/wiki/Source-maps:-l...
on top of that, there's right click on an element -> inspect, and it will tell you all you need to know, in any proper browser.
I really don't see a need for this.
The CSS you see in those tools is real decompressed CSS (organized a bit better than most stylesheets) and is pretty much exactly what you'd put in a stylesheet.
If you use Firebug or the equivalent across the browsers it's very easy to see the "maximised" CSS, but surely a setting to do this when viewing the CSS would be a good thing?