<?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>LR 7.1 SPA portlet - avoid script reload</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=111641080" />
  <subtitle>LR 7.1 SPA portlet - avoid script reload</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=111641080</id>
  <updated>2026-04-03T19:00:33Z</updated>
  <dc:date>2026-04-03T19:00:33Z</dc:date>
  <entry>
    <title>RE: LR 7.1 SPA portlet - avoid script reload</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113968566" />
    <author>
      <name>Charalampos Chrysikopoulos</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113968566</id>
    <updated>2019-06-12T13:41:13Z</updated>
    <published>2019-06-12T13:41:13Z</published>
    <summary type="html">Hi, I have seen the same problem. We have a portlet (that is migrated from 6.2) and it has a js include in its liferay-portlet.xml. The portlet is placed on a page and it works well.If we reload the page from the browser, then everything stays ok. &lt;br /&gt;But, if we load the same page from the navigation menu, then the same js resource seems to be load two times. This can be proven, by opening the network tab in the browser inspector and search for the js file.Every load we make from the navigation (which doesn&amp;#39;t trigger a page reload) adds a new instance of the js resource in the page. This problem disappears if we deactivate senna.js from the portal. By adding &amp;lt;single-page-application&amp;gt;false&amp;lt;/single-page-application&amp;gt; in the liferay-portlet.xml the problem isn&amp;#39;t solved.If anybody has an idea, place share it with us.Thanks in advance,Harry</summary>
    <dc:creator>Charalampos Chrysikopoulos</dc:creator>
    <dc:date>2019-06-12T13:41:13Z</dc:date>
  </entry>
  <entry>
    <title>LR 7.1 SPA portlet - avoid script reload</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111641079" />
    <author>
      <name>Chris Friedl</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111641079</id>
    <updated>2018-11-22T16:34:13Z</updated>
    <published>2018-11-22T16:34:13Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I have a custom&amp;nbsp;portlet - using javascript -&amp;nbsp;embedded in the footer
  of my LR theme.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;When SPA is enabled, everytime I navigate to a page in LR, the whole
  DOM&amp;nbsp;is thrown away and built again - including the loading of my
  included JS&amp;nbsp;files.. This causes me trouble because I am using
  "const" fields. When&amp;nbsp;navigation is done, the JS files are
  loaded and want to create the&amp;nbsp;"const" fields again -&amp;gt;
  this results in an error because the old const was not removed before.
  Only the DOM ist built newly - not the JS context.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;According to the LR documentation there is a&amp;nbsp;senna.js attribute which
  should avoid the reloading of JS resources:&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;&amp;amp;lt;script src="myscript.js" data-senna-track="permanent" /&amp;amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Unfortunately, this does not work at all on my LR Portal. The
  resources marked with the attribute above still get loaded again.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I include my JS resources in the view.jsp of my portlet.&lt;/p&gt;
&lt;p&gt;As I&amp;nbsp;mentioned before: the portlet is embedded in the footer of my theme.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Has anyone experience with preventing loading JS on navigation?&lt;/p&gt;
&lt;p&gt;The use of "const" is not my only concern ... there are
  other problems also which come with multiple loading of my used JS libraries.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thank you&lt;/p&gt;
&lt;p&gt;Chris&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Chris Friedl</dc:creator>
    <dc:date>2018-11-22T16:34:13Z</dc:date>
  </entry>
</feed>
