prefixfree

Break free from CSS -prefix- hell!

Only 4KB minified Fork me on GitHub
pre•fix•free |ˈprēˌfiksfrē| n. A script that lets you use only unprefixed CSS properties everywhere. It works behind the scenes, adding the current browser’s prefix to any CSS code, only when it’s needed.

Features

Limitations

Demo?

Check this page’s stylesheet ;-)

BTW: This page is a bit slow, because I went crazy with the CSS3 in it, to demonstrate prefixfree. It’s not prefixfree making it slow.

How to use

Just include prefixfree.js anywhere in your page. It is recommended to put it right after the stylesheets, to minimize FOUC

That’s it, you’re done!

Browser support

The target browser support is IE9+, Opera 10+, Firefox 3.5+, Safari 4+ and Chrome.

If it doesn’t work in any of those, it’s a bug so please report it. Just before you do, please make sure that it’s not because the browser doesn’t support a CSS3 feature at all, even with a prefix.

In older browsers like IE8, nothing will break, just properties won’t get prefixed. Which wouldn’t be useful anyway as IE8 doesn’t support much CSS3 ;)

Test drive

Test the prefixing that PrefixFree would do for this browser, by writing some CSS below:

FAQ

You're kinda destroying the whole idea behind vendor prefixes

Not really. Properties that already have a prefix won’t be altered. So, if you want to specify different behavior for a certain engine just use already prefixed properties.

How do I enable local testing?

Firefox (and IE?) natively support local XHR, so PrefixFree will work fine locally with them.

To enable local XHR for Chrome, you need to run it with the flag --allow-file-access-from-files.

To enable local XHR for Opera, you have to go to opera:config#UserPrefs|AllowFileXMLHttpRequest, check that option and Save.

Something like this belongs to the server-side

A server side script would need to add all prefixes, making the size of the CSS file considerably larger. Also, it should maintain a list of features that need prefixes, or add them all and unnecessarily bloat the stylesheet. Prefixfree automatically detects what needs a prefix and what doesn’t.

Also, a common argument against doing this on the client side, is that it makes the design rely on JavaScript. However, that is completely false: If JS is disabled, only some of the CSS3 won’t show. But if your design relies on CSS3 to be functional, you have bigger problems bro.

But every solution has its own pros and cons. If you would feel more comfortable with a server-side script, use that. Remember: nobody forced you to use PrefixFree. KTHXBAI ☺

Plugins

Extra code on top of PrefixFree that makes it more flexible, integrates it with different APIs etc

Dynamic DOM plugin

Originally a part of PrefixFree, it’s now a separate plugin. It makes PrefixFree take care of:

Things to be aware of:

Get the Dynamic DOM plugin now:

jQuery plugin

A tiny plugin (I didn’t even bother minifying it as it’s so small) that lets you set/get unprefixed CSS properties through jQuery's .css method.

Get the jQuery plugin now:

Tweet