In general, this is not possible.
However, if itβs normal that the Javascript you want to enable happens on every page of your portal, you can simply add a link to it inside your Liferay theme. Inside the theme, you can create dynamic content to get the correct JS URL, for example. using the portal property:
#set($jsUrl = $propsUtil.get("external.js.url")) <script type="text/javascript" src="$jsUrl"></script>
To have the same effect with the properties of the System, things get a little more complicated. As far as I know, there is no way to get the properties of the system from the Velocity variable introduced. Therefore, we need to create a small event handler hook that will insert this property into the Velocity context.
portal.properties
servlet.service.events.pre=my.custom.ServicePreAction
ServicePreAction.java
public class ServicePreAction extends Action { public void run(HttpServletRequest request, HttpServletResponse response) { Map<String,Object> veloVars = new HashMap<String,Object>(); veloVars.put("externalJSurl", System.getProperty("external.js.url")); request.setAttribute(WebKeys.VM_VARIABLES, veloVars); } }
portal_normal.vm
<script type="text/javascript" src="$externalJSurl"></script>
source share