Class: Rack::PageSpeed::Filters::InlineCSS
- Inherits:
-
Rack::PageSpeed::Filter
- Object
- Rack::PageSpeed::Filters::InlineCSS
- Defined in:
- lib/rack/pagespeed/filters/inline_css.rb
Instance Method Summary collapse
Instance Method Details
#execute!(document) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/rack/pagespeed/filters/inline_css.rb', line 4 def execute! document nodes = document.css('link[rel="stylesheet"][href]') return false unless nodes.count > 0 nodes.each do |node| file = file_for node next if !file or file.stat.size > (@options[:max_size] or 2048) inline = Nokogiri::XML::Node.new 'style', document inline.content = file.read node.before inline node.remove end end |