Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: RE: shared js files in different portlet project
Hi all.
Let say I have 2 portlet in different projects. (hq-task-web and branch-task-web)
Both portlet have common js function calculateDateline.js
Can I put this js file in common project so that both portlets can use it? (Except in themes)
Thanks
/Hairi
Hi ,
One way is to create war mvc portlet and add the js file under /src/main/webapp/main.js, and this js can be referred in any module by script tag
Ex.
|
come back with same question.
this make the portlet hang because access this approach is too slow.
If I use compileInclude, it will package in the same bundle?
Because its placed in META-INF
Thanks
compileInclude has no effect on load times. It will copy everything from the library you reference via compileInclude into the target bundle, but that doesn't change anything on the http level.
If you can go without it (and you can): You should. There are enough other solutions to the problem here.
1. You can create a separate portlet (js-portlet)
2. Add Js logic
3. Place the portlet on the same page.
4. You can control displaying of other portlets until js-portlet gets load by Liferay.portlet.ready() function in theme.
You should build a Theme-Contributor, which can add JS resources (as well as CSS) without touching a theme.
Powered by Liferay™