The things that the CSS3 specification has introduced are amazing. Too bad that we have to use vendor prefixes at the moment and for the foreseeable future. There are quite a few ways of dodging them though. The main one that seems to be gaining traction is a little tool called prefix free. It is a 2kb JavaScript file that adds the prefixes in the frontend. I have mixed feelings about this method.
My main reservation is the fact that it runs in the frontend. You would never use less.js in your frontend while in production, only in development. With prefix free you would use it in production and development. I would imagine that you would see the site flick into life in some older browsers as the prefixes are applied.
There are a few server side solutions as well, which seem a bit better in my opinion. Such as CSSPrefixer which runs on Python.
I did a bit of research using MDN and caniuse.com and came up with this spreadsheet. Don’t worry, it is on Google docs, not Microsoft Excel. It shows you where the majority of the vendor prefixes lie. I then compiled this data to LESS with this script on jsFiddle. This list of mixins is now implemented in my framework, more. So with my framework included in your project you can use mixins and not have to worry about vendor prefixes.
The above code will compile to this.
1 2 3 4 5 6 7 | a:hover { -webkit-transition: color 300ms ease; -moz-transition: color 300ms ease; -o-transition: color 300ms ease; -ms-transition: color 300ms ease; transition: color 300ms ease; } |
It may seem like a lot but it means that you will have as much backwards compatibility as possible.
So I suppose it comes down to your personal preference, you can opt for a frontend solution with prefix free. A backend one with CSSPrefixer or one that could be compiled in the front or backend such as more’s vendor prefix mixins.
I would love to have a discussion about these solutions and when you think we will not need them. So please, comment, tweet, email. And a merry christmas to anyone reading this if I don’t get to write another post before then.