Mastering Front-End Client Extensions in Liferay DXP

Author: Ajay Choudhary

Liferay Version: 7.4

Welcome to the exciting world of Liferay DXP! This blog post dives deep into the realm of frontend client extensions, a powerful tool for Liferay developers. Understanding client extensions is key to crafting unique user experiences on your Liferay sites without complex code modifications. Let’s explore these extensions and discover how to leverage them effectively in your projects.

Understanding Front-End Client Extensions

Frontend client extensions in Liferay DXP empower you to inject custom CSS, JavaScript, or even entire themes into your Liferay site. They are instrumental in transforming the look, feel, and behavior of your site’s front-end, all without needing extensive changes to the underlying codebase. Here are the primary types of frontend client extensions:

  • CSS Extension: Customize the visual style of your site.
  • JavaScript Extension: Inject custom JavaScript for added interactivity or functionality.
  • Theme CSS Extension: Revamp your site’s entire theme using a custom CSS file.
  • Theme Favicon Extension: Change the favicon (the small icon displayed in the browser tab) for your site.
  • Theme Sprite Map Extension: Replace the default icon sprite map with your custom set of icons.

YAML Files in Front-End Client Extension

YAML (YAML Ain’t Markup Language) plays a vital role in defining client extensions. It’s a human-readable format for data serialization. In Liferay DXP, YAML files configure the properties of client extensions. Here’s a simple example of a YAML file for a CSS extension:

In this example, the ‘type‘ specifies the extension type, ‘name‘ is a unique identifier for your extension, and ‘url‘ is the path to the CSS file.

Creating and Using CSS Client Extension

To create a CSS client extension, follow these steps:

  • Write your custom CSS file.
  • Create a YAML file to define your extension.
  • Deploy your extension to Liferay.

For example, if you want to change the background color of your site, you might write the following in

a ‘custom.css‘ file:

Then, define your extension in a YAML file:

Upload these files to your Liferay instance, and your site will have a new background color. It’s that simple!

JavaScript Client Extensions: Adding Dynamic Behavior

JavaScript Client Extensions allow you to enhance the interactivity of your Liferay site. For instance, you might want to add a custom alert message when a user visits a particular page. You would create a JavaScript file, say custom.js, with your desired script:

Your YAML configuration file for this JavaScript extension would be:

Once deployed, this script will execute whenever the page loads, creating a more engaging user experience.

Also Read: Creating React Client Extensions in Liferay

Theme CSS and Favicon Extension: Crafting Unique Site Identities

Theme CSS Extension are more comprehensive, allowing you to redefine the site’s entire look. You could, for instance, create a theme.css file with extensive styling rules. The corresponding YAML file might look like this:

Similarly, for a Theme Favicon Extension, you would link to your custom favicon file:

With these simple configurations, you have the power to dramatically alter the visual representation of your site, making it stand out.

Theme Sprite Map Extension: Customizing Icons

A Theme Sprite Map Extension allows you to replace the default set of icons used throughout the Liferay site with your custom sprite map. This is particularly useful if you want the icons to match your company’s branding. Here’s the process:

  1. Create an SVG file with your custom icons.
  2. Reference the SVG file in your YAML file:

Deploying this extension will update the icons across your site, bringing a cohesive and branded look to your user interface.

Best Client Extension Practices and Tips

Here are some valuable tips to keep in mind when working with client extensions:

  • Modularity is Key: Strive for modular and focused extensions. It’s better to have multiple smaller, well-defined extensions for specific purposes rather than a single, complex one.
  • Embrace Version Control: Utilize version control systems like Git to manage your extension files effectively. This is crucial for collaboration and tracking changes within your development team.
  • Ensure Browser Compatibility: Always test your CSS and JavaScript across different browsers to guarantee compatibility and a consistent experience for all users.
  • Prioritize Performance: Be mindful of the impact on your site’s performance. Overly complex JavaScript or CSS can slow down loading times.
  • Leverage Liferay Documentation: Refer to Liferay’s official documentation for detailed instructions and advanced configuration options related to client extensions.


Frontend client extensions in Liferay DXP provide a powerful and versatile way to enhance the front-end of your site. By understanding the different extension types and how to leverage YAML for configuration, you can significantly customize your Liferay site without delving deep into back-end code. Remember, the key is to start small, experiment, and gradually build your knowledge base. With these extensions at your disposal, you can create unique and engaging user experiences on your Liferay websites.

Happy coding!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Thanks !

Thanks for sharing this, you are awesome !