Class: Rack::PageSpeed::Filters::CombineJavaScripts
- Inherits:
-
Rack::PageSpeed::Filter
- Object
- Rack::PageSpeed::Filters::CombineJavaScripts
- Defined in:
- lib/rack/pagespeed/filters/combine_javascripts.rb
Instance Method Summary collapse
Instance Method Details
#execute!(document) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rack/pagespeed/filters/combine_javascripts.rb', line 12 def execute! document nodes = document.css('script[src]') return false unless nodes.count > 0 groups = group_siblings topmost_of_sequence(nodes) groups.each do |group| save group merged = merge group, document group.first.before merged group.map { |node| node.remove } end end |