/RequireCSS

A css plugin for RequireJS

Primary LanguageHTMLOtherNOASSERTION

RequireCSS (RequireJS css! plugin)

A RequireJS plugin which loads and waits for css files. Uses the standard load event on browsers which support it (IE, Firefox 9+, Opera) and uses a script tags load & error events as a workaround (Chrome, Safari, Firefox < 9). Detection of link load event support is done using a link element with a data url, which fires onload immediately when supported.

Only caveats in browsers not supporting the native link load event are that there will be JavaScript parse errors (since browsers try to interpret the dummy script tags used for load event detection) and there will be no RequireJS error message when a stylesheet could not be found/loaded. Also beware of IE's 31 style sheets limit (fixed in IE 10).

Compatibility

  • Firefox 1.0.1+
  • Safari 3.2+
  • Mobile Safari 4 (iOS 3.2)+
  • Chrome 1+
  • Opera 9.5+
  • IE 6+

Planned

  • Media-Query support
  • r.js optimizer support

Credits