开发者

How do I find the order in which javascript files are concatenated in Liferay?

So, in Liferay we have a ROOT/html/js folder with all core javascript. Can somebody explain me exact mechanism of creating 开发者_开发百科concatenated js-file. What is the difference between barebone.jsp and everything.jsp? Where in code I can see the order in which file are concatenated into one file?

I can see top_js.jspf file, but nevertheless it remaind unclear to me.

Thanks in advance.


Liferay's portal.properties is one of the best documented files. You'll find it either in the Liferay Wiki or in portal-impl.jar.

In there search for "barebone" or "everything" or just "Javascript". From there I've copied the following documentation:

#
# Set a list of JavaScript files that will be loaded automatically in
# /html/common/themes/top_js.jsp.
#
# There are two lists of files specified in the properties
# "javascript.barebone.files" and "javascript.everything.files".
#
# As the name suggests, the barebone list is the minimum list of JavaScript
# files required for most cases. The everything list includes everything
# else not listed in the barebone list.
#
# The two lists of files exist for performance reasons because
# unauthenticated users usually do not utilize all the JavaScript that is
# available. See the property "javascript.barebone.enabled" for more
# information on the logic of when the barebone list is used and when the
# everything list is used and how to customize that logic.
#
# The list of files are also merged and packed for further performance
# improvements. See the property "javascript.fast.load" for more details.
#

#
# Specify the list of barebone files.
#
# The ordering of the JavaScript files is important.
#
# The Liferay scripts are grouped in such a way, that the first grouping
# denotes utility scripts that are used by the second and third groups. The
# second grouping denotes utility classes that rely on the first group, but
# does not rely on the second or third group. The third grouping denotes
# modules that rely on the first and second group.

javascript.barebone.files= ... (omitted here, multiline)

The following sections (in order to not copy everything here) might also contain interesting information for your case. But I guess your question is answered with the parts from above - read the rest in portal.properties.

Edit: To answer to your comment: The order is documented above, it's top to bottom, as the later files depend on the earlier. Further the following property might give a hint on reasoning:

#
# Set this property to false to always load JavaScript files listed in the
# property "javascript.everything.files". Set this to true to sometimes
# load "javascript.barebone.files" and sometimes load
# "javascript.everything.files".
#
# The default logic is coded in com.liferay.portal.events.ServicePreAction
# in such a way that unauthenticated users get the list of barebone
# JavaScript files whereas authenticated users get both the list of barebone
# JavaScript files and the list of everything JavaScript files.
#
javascript.barebone.enabled=true

The reason behind all of this is that in many installations customers want to minimize the amount of data transferred and javascript executed. If everything would be fully dynamic, this would result in lots of files to be transferred, which takes a lot of time through http. "barebones" and "everything" concatenate and minify all of the files and transfer them as one. Typically, transferring just one file is a lot faster than transferring multiple files, even if all add up to the same length.

And while one can argue about the amount of documentation for Liferay in general, I'd say you can't argue about portal.properties being among the best documented files in Liferay. Take a look at it - just doing so will give you a lot of insight of what neat things you can do with Liferay.


Please remember that the barebones listing is the javascript file listed in a logged out state. The everything list is a combination of the everything list and the barebones listing .

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜