Last updated

scripts

To insert custom scripts in the head or body of a page.

Options

OptionTypeDescription
head[Script object]Inserts scripts in the head tags of the page.
body[Script object]Inserts scripts before the close body tag of the page.

Script object

OptionTypeDescription
srcstringREQUIRED. URL or path to script.
inlinebooleanInlines the script content into the page. Improves performance for small scripts. Default value: false.
asyncbooleanSpecifies to add the async attribute to the script tag. Default value: false.
crossoriginstringAdds the crossorigin attribute with corresponding value to the script tag.
deferbooleanSpecifies to add the defer attribute to the script tag. Default value: false.
fetchprioritystringAdds the fetchpriority attribute with corresponding value to the script tag. Possible values: high, low, or auto. Default value: auto.
integritystringAdds the integrity attribute with corresponding value to the script tag.
modulebooleanSpecifies to add the module attribute to the script tag. Default value: false.
nomodulebooleanSpecifies to add the nomodule attribute to the script tag. Default value: false.
noncestringAdds the nonce attribute with corresponding value to the script tag.
referrerpolicystringAdds the referrerpolicy attribute with corresponding value to the script tag. Possible values: no-referrer, no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url, ''. Default value: strict-origin-when-cross-origin (with fallback to '').
typestringAdds the type attribute with corresponding value to the script tag.

Examples

scripts:
  head:
    - src: 'https://example.com/script.js'
    - src: ./scripts/script.js
  body:
    - src: 'https://analytics.google.com/ga.js'
      crossorigin: anonymous
      defer: true

The example above will produce following script tags:

  <script src="https://example.com/script.js"></script>
  <script src="/static/script.abf4dc37439374dfa2.js"></script>
</head>
<body>
  ...
  <script src="https://analytics.google.com/ga.js" crossorigin="anonymous" defer>
</body>

Resources