Page MenuHomePhabricator

CSSMin should automatically add vendor prefixes for CSS3 properties
Closed, DeclinedPublic

Description

So when I write border-radius: 20px;, -moz-border-radius: 20px;, -webkit-border-radius: 20px; etc. will be added automatically.


Version: unspecified
Severity: enhancement

Details

Reference
bz27933

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:25 PM
bzimport set Reference to bz27933.
bzimport added a subscriber: Unknown Object (MLST).

What's the proposed behavior when such private rules already exist neaby?

I think figuring out ways to make development easier is clever and useful, but we have to be careful because we process CSS from libraries like jQuery UI, or other jQuery plugins all the time, and we need to not make assumptions about their code. Also, given that, what you are proposing might possibly require parsing to do right (not 100% sure, but I suspect it might) and parsing CSS is another tricky business because of CSS hacks being used in said libraries.

I was going to also point out, that there are libraries like SASS, xCSS, and Less that do meta CSS programming. Because these start from a more sanitary source, they can do tricky things. If there's a PHP implementation of one of these that we like, we could consider adding that to core and supporting that as a style format. ResourceLoader could notice by inference or be told by configuration that the style needs to be processed using X algorithm, and all should be well. It could be used as a pre-processing step, so existing minification, URL remapping and image embedding would still work.

Less has a javascript implementation. So you can just:

<link rel="stylesheet/less" type="text/css" href="styles.less">

^^^^^^^^^^^^^^

<script src="less.js" type="text/javascript"></script>

The javascript will handle all the magic for you http://lesscss.org/

See bug 40964 for Less/SASS/whatever support and why it probably can't be implemented right now.

The second point from bug 40964 comment 1 applies here as well: "There is currently (for debug, among other reasons) the paradigm that the post-processor only enhances scripts/styles, never as a requirement for it to be functional. So in the current way of things, any pre-processor wouldn't be an option.".

Additionally, for some CSS properties (for examples ones related to gradients) the -prefix- syntax is different than the final, accepted one; we can't blindly add the prefixed properties every time.

And also, the usefulness of this would IMO be quite minimal.

Therefore I suggest WONTFIXing this bug.

I agree with WONTFIX:

  • The vendor prefixes might have different syntax
  • This is beyond optimisation of code and actually adds functionality, this is something for a a more advanced and explicit pre-processor (e.g. SASS, LESS), not something to silently add during minification.