This wiki does not contain official documentation and is currently deprecated and read only. Please try reading the documentation on the Liferay Developer Network, the new site dedicated to Liferay documentation. DISCOVER Build your web site, collaborate with your colleagues, manage your content, and more. DEVELOP Build applications that run inside Liferay, extend the features provided out of the box with Liferay's APIs. DISTRIBUTE Let the world know about your app by publishing it in Liferay's marketplace. PARTICIPATE Become a part of Liferay's community, meet other Liferay users, and get involved in the open source project. jQuery in liferay 6.1.20 and 6.2
If liferay portal is rich consumer of jquery and all portlets are using it through out the application, then following is the approach that I am using in my project.
1. Create liferay hook and add jquery libraries to /html/js/jquery folder.
2. Override top_js.jspf file in your hook [It is under /html/common/themes/top_js.jspf].
Add
<script src="<%= HtmlUtil.escape(PortalUtil.getStaticResourceURL(request, themeDisplay.getCDNDynamicResourcesHost() + themeDisplay.getPathJavaScript() + "/barebone.jsp", "minifierBundleId=javascript.jquery.files", javaScriptLastModified)) %>" type="text/javascript"></script>
After
<script src="<%= HtmlUtil.escape(PortalUtil.getStaticResourceURL(request, themeDisplay.getCDNDynamicResourcesHost() + themeDisplay.getPathJavaScript() + "/barebone.jsp", "minifierBundleId=javascript.barebone.files", javaScriptLastModified)) %>" type="text/javascript"></script>
AND
Add
<script src="<%= HtmlUtil.escape(PortalUtil.getStaticResourceURL(request, themeDisplay.getCDNDynamicResourcesHost() + themeDisplay.getPathJavaScript() + "/barebone.jsp", "minifierBundleId=javascript.jquery.files", javaScriptLastModified)) %>" type="text/javascript"></script>
After
<script src="<%= HtmlUtil.escape(PortalUtil.getStaticResourceURL(request, themeDisplay.getCDNDynamicResourcesHost() + themeDisplay.getPathJavaScript() + "/everything.jsp", "minifierBundleId=javascript.everything.files", javaScriptLastModified)) %>" type="text/javascript"></script>
3. Create portal.properties file and add following properties to it.
include-and-override=portal-ext.properties
javascript.jquery.files=\
jquery/jquery-min.js
javascript.bundle.ids=\
javascript.barebone.files,\
javascript.everything.files,\
javascript.jquery.files
javascript.bundle.dir[javascript.jquery.files]=/html/js
NOTE: If you are not seeing jquery files loading then add above properties to portal-ext.properties and restart server.
Above approach is working absolutely fine in my project and I have eliminated adding script tags to portal_normal.vm under theme. Even I have overcome page load performance issue where it was loading may jquery libraries one after other where it was consuming some time in loading portlet data.
Please refer performance explanation given on each properties in portal.properties file.