Skip to content

Instantly share code, notes, and snippets.

@devinus
Created May 26, 2010 22:38
Show Gist options
  • Save devinus/415179 to your computer and use it in GitHub Desktop.
Save devinus/415179 to your computer and use it in GitHub Desktop.
Turn CSS rules into inline style attributes using jQuery
(function ($) {
var rules = document.styleSheets[document.styleSheets.length-1].cssRules;
for (var idx = 0, len = rules.length; idx < len; idx++) {
$(rules[idx].selectorText).each(function (i, elem) {
elem.style.cssText += rules[idx].style.cssText;
});
}
$('style').remove();
$('script').remove();
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment