Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
C

CSS-Filters-Polyfill

> 编程语言
Open source

This polyfill takes the official CSS filters syntax and translates it to the different equivalent techniques that the browsers know for those effects

750 stars0 likes2 views
WebsiteGitHub

About

This polyfill takes the official CSS filters syntax and translates it to the different equivalent techniques that the browsers know for those effects

Polyfilter - a CSS Filters Polyfill

This polyfill takes the official CSS Filter Effects syntax, which spec you can find over here and translates it to the different equivalent techniques that the browsers know for those effects:

  • Prefixing for WebKit/Blink-based browsers
  • Translating into SVG-filters for Firefox
  • Translating into DirectX-filters for IE 6-9

For instance, this allows you to assign a property like

filter: blur(10px);

in your stylesheets and the polyfill will take care that it works in as many browsers as possible.

Supported Filters

  • grayscale*
  • sepia*
  • blur
  • invert*
  • brightness
  • drop-shadow

Have a look at this overview.

* the IEs only support 0% or 100% values

Supported Browsers

Currently the polyfill is able to support

  • Chrome 20+ (brightness filter 28+),
  • Opera 15+
  • Safari 6+,
  • Yandex 1+,
  • Firefox 4+,
  • IE 6 - 9 on desktop (IE 6 & 7 slightly degraded),

and

  • iOS 6+ Safari/Chrome/Webview
  • Chrome 28+ on Android,
  • Opera Mobile 14+,
  • Blackberry Browser 10+,
  • Firefox 4+ on Mobile,
  • IE on Windows Phone 7, which just supports grayscale.

Also have a look at http://caniuse.com/css-filters

Not supported Browsers

  • IE 10+,
  • older Presto-based Operas,
  • Opera Mini,
  • Android browser

A word regarding IE 10+

Why is IE 6 - 9 supported, but not IE 10 or higher? Well, since Microsoft decided to switch sides and to now follow standards, they killed their old proprietary filters beginning with IE 10 which I rely on for emulation.

Altough they did introduce SVG filters sadly those are limited to a usage inside SVGs. They cannot be applied to HTML-elements.

Even triggering legacy mode does not help any more. So this is why we are left at the end with no hook/support at all in IE10+ :(

And what about those Presto-based Opera?

Older Operas with Presto engine are not supported, as they offer none of the hooks I used.

Setup

First create a `


This is important both for the old IEs and the web worker script.  

Should you not want the document stylesheets to not get automatically parsed, like when your plan is to apply filters only via JavaScript, then you can additionally set a `polyfilter_skip_stylesheets` switch:

```html

Then you link cssParser.js and css-filters-polyfill.js from the polyfill library.

xml

…

css
.element{
	filter: blur(10px);
}

And you can even assign two filters at once, e.g.

css
.element{
	filter: sepia(1) blur(10px);
}

Programmatic assignment

In addition the polyfill also extends the JavaScript CSSStyleDeclaration object, so that you can assign filter styles on the fly as you are used to with CSS. But instead of exposing a element.style.filter property as one would think, you instead need to address element.style.polyfilter, e.g.:

javascript
element.style.polyfilter = 'blur(10px)';

or via jQuery:

javascript
$(element).css('polyfilter','blur(10px)');

And, again, you can assign two filters at once, e.g.

javascript
element.style.polyfilter = 'sepia(1) blur(10px)';

Note: This does not work for IE 6 & 7. They just ignore any programmatic assignment.

Animations

Likewise, if you want to animate a filter, then you do this:

javascript
var value = 0,   
    increment = 1  
    elem = document.getElementById('filtered');

window.setInterval(function(){  
    value += increment;  
    elem.style.polyfilter = 'blur(' + value + 'px)';  
    if(value >= 10 || value 
    Header set Access-Control-Allow-Origin "*"
  

Or if you want more security, replace the * with the requesting domain:


  
    Header set Access-Control-Allow-Origin "requestingdomain.com"
  

Examples and Howtos

See http://schepp.github.io/CSS-Filters-Polyfill/examples/

License

Copyright (c) 2012 - 2013 Christian Schepp Schaefer

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

JavaScript

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言