提交 033ac185 编写于 作者: J Jonathan Fleckenstein

don't preload for defered scripts and disable push

上级 680db1df
......@@ -90,7 +90,7 @@ def javascript_include_tag(*sources)
sources_tags = sources.uniq.map { |source|
href = path_to_javascript(source, path_options)
preload_links << "<#{href}>; rel=preload; as=script"
preload_links << "<#{href}>; rel=preload; as=script; nopush" unless options["defer"]
tag_options = {
"src" => href
}.merge!(options)
......@@ -140,7 +140,7 @@ def stylesheet_link_tag(*sources)
sources_tags = sources.uniq.map { |source|
href = path_to_stylesheet(source, path_options)
preload_links << "<#{href}>; rel=preload; as=style"
preload_links << "<#{href}>; rel=preload; as=style; nopush"
tag_options = {
"rel" => "stylesheet",
"media" => "screen",
......
......@@ -513,10 +513,15 @@ def test_javascript_include_tag_without_request
def test_should_set_preload_links
stylesheet_link_tag("http://example.com/style.css")
javascript_include_tag("http://example.com/all.js")
expected = "<http://example.com/style.css>; rel=preload; as=style,<http://example.com/all.js>; rel=preload; as=script"
expected = "<http://example.com/style.css>; rel=preload; as=style; nopush,<http://example.com/all.js>; rel=preload; as=script; nopush"
assert_equal expected, @response.headers["Link"]
end
def test_should_not_preload_links_with_defer
javascript_include_tag("http://example.com/all.js", defer: true)
assert_equal "", @response.headers["Link"]
end
def test_image_path
ImagePathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册