JS that is available in ALL pages
You can reuse the mechanism that Liferay uses for loading a lot of JS files at every page load.
- Create a hook that will add your JS file in ROOT webapp
- Add the path to your blabla.js file to one of those properties:
JS that is specific to a theme
- Put your blabla.js in the folder “js” of your theme
- Import your blabla.js file in Velocity template “portal-normal.vm” using HTML “script” tag
If you need to use the JS in multiple themes, use theme inheritance mechansim.
JS that is specific to a portlet
In every portlet you will surely need to write some JS to do some client validation or some visual logic.
- Put your blabla.js in the folder “js” of your portlet
- Import the JS file at top/bottom of the portlet (depending if you need the script to be executed at the beggining/end of the displaying of the portlet page)