Message Boards
shared js files in different portlet project
shared js files in different portlet project
New Member Posts: 17 Join Date: 4/9/20 Recent PostsHi 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
RE: shared js files in different portlet project
Liferay Master Posts: 591 Join Date: 8/8/14 Recent PostsHi ,
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.
|
RE: RE: shared js files in different portlet project
New Member Posts: 17 Join Date: 4/9/20 Recent Postscome 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
RE: RE: shared js files in different portlet project
Liferay Legend Posts: 6403 Join Date: 9/23/08 Recent PostscompileInclude 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.
RE: shared js files in different portlet project
Junior Member Posts: 49 Join Date: 11/18/14 Recent Posts1. 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.
RE: shared js files in different portlet project
Liferay Legend Posts: 6403 Join Date: 9/23/08 Recent PostsYou should build a Theme-Contributor, which can add JS resources (as well as CSS) without touching a theme.