JavaScript YAML Configuration Reference

You can define a JavaScript client extension with a client-extension.yaml file.

Usage Details

This client-extension.yaml file defines a JavaScript client extension:

able-global-js:
   name: Able JS
   scriptElementAttributes:
      async: true
      data-attribute: "value"
      data-senna-track: "permanent"
      fetchpriority: "low"
   type: globalJS
   url: global.js

The required url property defines the JavaScript resource file’s location. When enabled on a page, JavaScript at this path runs on each page load.

The example workspace includes a complete JavaScript client extension.

YAML Properties

These properties are specific to JavaScript client extensions:

NameData TypeDescription
urlURL(Required) The path to the JavaScript file added to the HEAD of the page when the client extension is enabled. The complete URI is prefixed by the baseURL value.
scriptElementAttributesStringBeginning in Liferay DXP 2024.Q2/Portal 7.4 GA120, you can add string and Boolean attributes to the HTML script element. Use the format name: "value" for strings and name: value for Booleans.
scopeStringBeginning in Liferay DXP 2024.Q4/Portal 7.4 GA129, you can set the scope to company to apply the JavaScript Client Extension to all the pages of an instance, including the administrative pages (e.g., site administration and the control panel). The default is layout, and applies only to site pages as set by the administrator.
scriptLocationStringBeginning in Liferay DXP 2024.Q4/Portal 7.4 GA129, you can specify whether the script runs in the page head or bottom. This only applies when the scope is company.

See Frontend Client Extension Properties for properties common to all frontend client extensions.

Capabilities

Product

Contact Us

Connect

Powered by Liferay
© 2024 Liferay Inc. All Rights Reserved • Privacy Policy