In this post I’m going to describe how Liferay loads JS files for the whole portal and how we can add new JS imports.
A lot of JS files are loaded by Liferay portal. In the portal.properties file you can see the list of files imported when a user is not connected (“barebone”) and when a user is connected (“everything”).
The two properties are located in portal.properties file:
Then, either barebone or everything JS files are loaded using HTML “script” tag in the file “top_js.jspf”:
The JS files that can be added to these two lists must be located in the folder “/html/js” of a webapp.
Try to always import JS files that are in a project that is always deployed in your application server to ensure the JS file imported will always exist, for example in a hook or a theme (I always liked the word ‘always’).
This pretty simple mechanism lets you add JS files at portal level in a proper way.