2

因此,在 Liferay 中,我们有一个ROOT/html/js包含所有核心 javascript 的文件夹。有人可以解释一下创建串联 js 文件的确切机制吗?barebone.jsp 和everything.jsp 有什么区别?在代码中的什么位置我可以看到文件连接到一个文件中的顺序?

我可以看到top_js.jspf文件,但我仍然不清楚。

提前致谢。

4

2 回答 2

5

Liferay 的portal.properties 是记录最好的文件之一。您可以在 Liferay Wiki 或 portal-impl.jar 中找到它。

在那里搜索“准系统”或“一切”或只是“Javascript”。从那里我复制了以下文档:

#
# 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)

以下部分(为了不在这里复制所有内容)也可能包含您案例的有趣信息。但我想您的问题已通过上面的部分得到解答 - 请阅读 portal.properties 中的其余部分。

编辑:回答您的评论:上面记录了顺序,它是从上到下的,因为后面的文件取决于前面的文件。此外,以下属性可能会提示推理:

#
# 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

所有这一切背后的原因是,在许多安装中,客户希望最小化传输的数据量和执行的 javascript。如果一切都是完全动态的,这将导致需要传输大量文件,这需要通过 http 花费大量时间。“barebones”和“everything”连接并缩小所有文件并将它们作为一个文件传输。通常,仅传输一个文件比传输多个文件要快得多,即使所有文件加起来的长度相同。

虽然人们通常会争论 Liferay 的文档数量,但我想说你不能争论 portal.properties 是 Liferay 中最好的文档文件之一。看看它 - 这样做会让您深入了解 Liferay 可以做哪些巧妙的事情。

于 2011-09-02T18:43:14.047 回答
0

请记住,准系统列表是在注销状态下列出的 javascript 文件。Everything 列表是 Everything 列表和准系统列表的组合。

于 2015-02-06T10:26:27.010 回答