Flowdock
method

preload_link_tag

Importance_2
Ruby on Rails latest stable (v6.1.7.7) - 0 notes - Class: ActionView::Helpers::AssetTagHelper
preload_link_tag(source, options = {}) public

Returns a link tag that browsers can use to preload the source. The source can be the path of a resource managed by asset pipeline, a full path, or an URI.

Options

  • :type - Override the auto-generated mime type, defaults to the mime type for source extension.

  • :as - Override the auto-generated value for as attribute, calculated using source extension and mime type.

  • :crossorigin - Specify the crossorigin attribute, required to load cross-origin resources.

  • :nopush - Specify if the use of server push is not desired for the resource. Defaults to false.

  • :integrity - Specify the integrity attribute.

Examples

preload_link_tag("custom_theme.css")
# => <link rel="preload" href="/assets/custom_theme.css" as="style" type="text/css" />

preload_link_tag("/videos/video.webm")
# => <link rel="preload" href="/videos/video.mp4" as="video" type="video/webm" />

preload_link_tag(post_path(format: :json), as: "fetch")
# => <link rel="preload" href="/posts.json" as="fetch" type="application/json" />

preload_link_tag("worker.js", as: "worker")
# => <link rel="preload" href="/assets/worker.js" as="worker" type="text/javascript" />

preload_link_tag("//example.com/font.woff2")
# => <link rel="preload" href="//example.com/font.woff2" as="font" type="font/woff2" crossorigin="anonymous"/>

preload_link_tag("//example.com/font.woff2", crossorigin: "use-credentials")
# => <link rel="preload" href="//example.com/font.woff2" as="font" type="font/woff2" crossorigin="use-credentials" />

preload_link_tag("/media/audio.ogg", nopush: true)
# => <link rel="preload" href="/media/audio.ogg" as="audio" type="audio/ogg" />
Show source
Register or log in to add new notes.