You can use the `#{resource['ivy-webcontent:mypath']}` not only in *.xhtml .xhtml files but also in *.css .css and *.js .js files that you load over the jsf resource mechanism.
JSF will automatically replace and expand the #{resource[]} `#{resource[...]}` with the right url.
In your example use `#{resource[...]}` in the xportal-common.js file to reference other files in the webContent folder. JSF will automatically replace the #{resource[...]} `#{resource[...]}` with the right url when sending the file to the web browser.
Have a look at the file webContent/layouts/styles/ivy-common.css `webContent/layouts/styles/ivy-common.css` in the HtmlDialogDemos project to see how #{resource[...]} `#{resource[...]}` can be used in a *.css .css file. This also works in *.js .js files.