usethetics / REM-unit-polyfill

A polyfill to parse CSS links and rewrite pixel equivalents into head for non supporting browsers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

REM unit polyfill

No fluff here. You can load this conditionally or just include a reference in your page. This will test for REM support, although we all know IE8 and below is where the issue lies.

An example is included that is small and you can bring up in your favorite browser to see how it works. Once lack of support is determined, the polyfill reads all links for stylesheets and finds selectors that have rules using the REM unit. It then recalculates those to PX and writes them in the head to override in the cascade. Magic.

Special shout out to Lucas Serven for the first version and all the amazing RegEx that's gone into this.

It's been tested on a large production publishing site and worked great in with minor performance differences.

We're always open to suggestions and/or improvements, so please fork!

License

This content is released under the MIT License.

About

A polyfill to parse CSS links and rewrite pixel equivalents into head for non supporting browsers