<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>Influencing the order of combined JavaScript files</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=113238042" />
  <subtitle>Influencing the order of combined JavaScript files</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=113238042</id>
  <updated>2026-04-03T21:58:54Z</updated>
  <dc:date>2026-04-03T21:58:54Z</dc:date>
  <entry>
    <title>RE: Influencing the order of combined JavaScript files</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113274111" />
    <author>
      <name>Jan Tošovský</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113274111</id>
    <updated>2019-04-17T14:32:24Z</updated>
    <published>2019-04-17T14:32:24Z</published>
    <summary type="html">Hi Andrew,&lt;br /&gt;&lt;br /&gt;thanks for various approaches to share JS libraries, good to know.&lt;br /&gt;&lt;br /&gt;In my case all those modules/portlets will end up on a single page, kind of dashboard. In this controlled environment I can afford the luxury to bring the tight dependency of my portlets (mostly charts) to a base one, which contains all required dependencies (moment.js, chart.js, chartjs-plugin-datalabels.js, in the correct order) and it is placed before the rest of components.&lt;br /&gt;&lt;br /&gt;I&amp;#39;ve already implemented this for few portlets and it seems to be a viable option.&lt;br /&gt;&lt;br /&gt;Thanks,&lt;br /&gt;&lt;br /&gt;Jan</summary>
    <dc:creator>Jan Tošovský</dc:creator>
    <dc:date>2019-04-17T14:32:24Z</dc:date>
  </entry>
  <entry>
    <title>RE: Influencing the order of combined JavaScript files</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113262525" />
    <author>
      <name>Andrew Jardine</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113262525</id>
    <updated>2019-04-16T19:54:30Z</updated>
    <published>2019-04-16T19:54:30Z</published>
    <summary type="html">Hi Jan,&lt;br /&gt;&lt;br /&gt;This looks similar to what you are asking/said --&lt;br /&gt;&lt;br /&gt;&lt;a href="https://community.liferay.com/blogs/-/blogs/sharing-js-across-modules"&gt;https://community.liferay.com/blogs/-/blogs/sharing-js-across-modules&lt;br /&gt;&lt;br /&gt;&lt;/a&gt;If you need it on all pages, but don&amp;#39;t want to (or can&amp;#39;t) include it in the theme you could use this trick. It&amp;#39;s for an older version of Liferay but it still applies in 7+ -- I&amp;#39;ve used static portlets more than once in this new OSGI world&lt;br /&gt;&lt;br /&gt;&lt;a href="https://community.liferay.com/blogs/-/blogs/adding-a-javascript-to-every-page"&gt;https://community.liferay.com/blogs/-/blogs/adding-a-javascript-to-every-page&lt;br /&gt;&lt;br /&gt;&lt;/a&gt;Does any of this help?&lt;br /&gt;&lt;a href="https://community.liferay.com/blogs/-/blogs/adding-a-javascript-to-every-page"&gt;&lt;br /&gt;&lt;/a&gt;As an aside, I know it seems odd (and broken) to have the resources loaded on every page but you have to consider the fact that in the portlet world it&amp;#39;s no uncommon to encapsulate everything the portlet needs to work as part of the package right? Technically there is no way to know if two portlets that share a resource will be on the same page since technically speaking you should think of each portlet as it&amp;#39;s own application. I understand what you want to do of course, and there are lots of people out there fighting to build SPAs on portals. I think the more common approach for what you are trying to do though is to have one (monolith) portlet on the page so that the resources are only loaded once and then use Angular, or VUE, or NPM or React or whatever to update the sections. So your individual portlets become the components of those JS framworks and you package the whole kits as a single portlet.</summary>
    <dc:creator>Andrew Jardine</dc:creator>
    <dc:date>2019-04-16T19:54:30Z</dc:date>
  </entry>
  <entry>
    <title>RE: Influencing the order of combined JavaScript files</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113253505" />
    <author>
      <name>Jan Tošovský</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113253505</id>
    <updated>2019-04-16T12:51:45Z</updated>
    <published>2019-04-16T12:51:45Z</published>
    <summary type="html">After various tests I can see some correlation between the order and Module/Portlet names.&lt;br /&gt;&lt;br /&gt;The more serious thing is observation same libraries referenced from different modules are bundled multiple times. So I either need to keep all portlets in same module or to move javascript libraries into dedicated module/portlet, which needs to be placed to any page with the instance of my script-less portlet.</summary>
    <dc:creator>Jan Tošovský</dc:creator>
    <dc:date>2019-04-16T12:51:45Z</dc:date>
  </entry>
  <entry>
    <title>Influencing the order of combined JavaScript files</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113238041" />
    <author>
      <name>Jan Tošovský</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113238041</id>
    <updated>2019-04-15T16:14:39Z</updated>
    <published>2019-04-15T16:14:39Z</published>
    <summary type="html">There are multiple portlets on a single page, all of them have some &lt;span style="font-family: Courier New, Courier, monospace"&gt;com.liferay.portlet.header-portlet-javascript&lt;/span&gt; entries, which are combined together into a single bundle.&lt;br /&gt;However, in my case the order matters. Unfortunately, the portlet placement is not taken into an account, so some libs from second portlet are bundled before the first portlet which breaks some functionality.&lt;br /&gt;&lt;br /&gt;Is there any solution for this? &lt;br /&gt;&lt;br /&gt;My only (crazy) idea is to create dummy potlet cummulating all libs used on that page and remove javascript references from other portlets.</summary>
    <dc:creator>Jan Tošovský</dc:creator>
    <dc:date>2019-04-15T16:14:39Z</dc:date>
  </entry>
</feed>
