Your main issue is the way you are implementing your filter: none;
(or, the way you are removing the previously-set grayscale filter). You are right to say that:
as far as I know CSS does not STOP checking other rules if seen like
filter: none;?
but that is precisely the issue! It seems setting the filter to none is a lot more resource-intensive than simply changing the grayscale back to 0%
!
I found a quote in the book Pro CSS3 Animation by Dudley Storey that corroborates this hypothesis:
"Note that you cannot transition smoothly to a state of 'none' or no filter applied; the filter must be given a fresh value" (Storey, 113)
Therefore, in Example 1, Safari is reading the CSS and is essentially being left with the much more labor-intensive feat of removing all filters rather than setting only the grayscale filter to 0%
. In Example 2, Safari sees the -webkit-filter: grayscale(0%);
last, which means it is the CSS it executes (and has an easier time doing it).
While I think this answers the question, I hope more experienced people share their input. I'm not really satisfied myself, because I've been told that convention is to put "generic" CSS tags before your own (putting -webkit
, -moz
, before other CSS), and the only information I found on Apple Safari Documentation is a vague warning:
Filters are visual effects that can be applied to images and other
HTML elements... These filters are resource-intensive. Use them
sparingly and only when necessary. Be sure to test your content on a
multitude of computers and devices to assert that rendering
performance is not hampered, especially if animating. Source
The easiest (and most compliant with convention, it seems) is to simply remove filter:none;
entirely, since it is redundant and frankly unnecessary if the only filter you are removing is grayscale.
I hope it helps, and that the answer is coherent. It's a little late for me so forgive me for any errors!