(888) 685-3101 ext. 2

Liferay themes are an easy way to transform the look and feel of your portal. Theme development is not difficult and can be done with Velocity or FreeMarker templates. You can also create a JSP-based theme but that’s less common.

We can talk for quite a while about theme development; however, this blog targets performance concerns. Bad decisions in your theme can easily lead to performance problems on your site. You must consider that the theme will be loaded on every page within the site. Keeping a light weight theme will always help with performance. You should only include common assets (CSS & JavaScript) used for the entire website in the theme.

I won’t go into detail on the “usual suspects” of website performance. Those topics include items such as minifying your JavaScript & CSS, reducing HTTP requests, optimizing images, etc. There are plenty of other blogs online with those general website performance tips. There are also Firefox plugins such as YSlow that can help here.

My biggest recommendation is to reduce dynamic logic within the theme. As an example, a client I worked with in the past added their font files to the Liferay document library. This by itself isn’t necessary a bad thing. However, they made a theme change to load all 5 font files (eot, woff, ttf, etc). This is where the problem started. They have a custom service which is called 5 times on each page load to build the link URL needed to load the font file.

I will not elaborate all the details of this service, but it was poorly written to say the least. It started with a lookup for all document library files in the root folder using a string array of MIME types. It then iterated through the list several times, trimming down the results to the one desired font file. Lastly, it built the relative path to the document library file by concatenating strings together… and no, they did not even use a string buffer. Worst of all, this logic is then performed 5 times on every page load.

All of this logic seemed like a waste and is definitely not helping site performance. These font files will rarely (if ever) change, so even storing them in the document library is overkill. You can easily include the font files in your theme and load them directly without all this logic.

In a low traffic website, these issues may not have a large impact on performance. In my experience, it’s usually several “relatively minor” issues combined that cause the overall problem. That’s when you run the before/after performance tests and see the impacts under load. Even shaving a half a second off every page load can make a drastic impact on the user experience.

Performance concerns are not something that should be addressed once you have performance problems. Our industry is full of stories about websites that became extremely popular in a very short time-frame. To make a long story short, you should strive to limit the dynamic logic within your theme. My recommendation is to keep your themes as light weight as possible. The users of your portal will thank you.

For More Information

For more information about expert help with your Liferay implementation, check out https://www.xtivia.com/portal/liferay-portal, or contact us at https://www.xtivia.com/contact-us

Share This