diff options
author | Mike Greiling <mike@pixelcog.com> | 2018-05-09 14:21:54 -0500 |
---|---|---|
committer | Mike Greiling <mike@pixelcog.com> | 2018-05-09 14:21:54 -0500 |
commit | 180fd4baf2fab39baa6396455de2f7c4d045d726 (patch) | |
tree | ecc3f95d4e40966649682631d06bdbe30593087a | |
parent | 698b7ca2e4a4ed3efd464290bb25c653b53bf0ed (diff) | |
download | gitlab-ce-add-prefetch-preload-support.tar.gz |
refactor webpack_link_tagsadd-prefetch-preload-support
-rw-r--r-- | app/helpers/webpack_helper.rb | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/app/helpers/webpack_helper.rb b/app/helpers/webpack_helper.rb index 6ec9bce6542..d040a869dc3 100644 --- a/app/helpers/webpack_helper.rb +++ b/app/helpers/webpack_helper.rb @@ -35,10 +35,10 @@ module WebpackHelper end [ + *webpack_link_tags(preload, rel: "preload", as: "script"), + *webpack_link_tags(prefetch, rel: "prefetch"), javascript_include_tag(*chunks), - webpack_link_tag(*preload, rel: "preload", as: "script"), - webpack_link_tag(*prefetch, rel: "prefetch") - ].reject(&:empty?).join("\n").html_safe + ].join("\n").html_safe end def webpack_entrypoint_paths(source, extension: nil, exclude_duplicates: true) @@ -104,11 +104,13 @@ module WebpackHelper File.join(webpack_public_host.to_s, relative_path.to_s, webpack_path.to_s, '') end - def webpack_link_tag(*paths) - options = paths.extract_options!.stringify_keys + def webpack_link_tags(paths, options = {}) paths.uniq.map do |path| - tag_options = { "href" => path }.merge!(options) + tag_options = { + rel: "prefetch", + href: path + }.merge!(options) content_tag(:link, "", tag_options) - end.join("\n").html_safe + end end end |