By default, Liferay DXP unloads CSS resources from the <head>
element on
navigation. JavaScript resources in the <head>
, however, are not removed on
navigation. This functionality can be customized by setting the resource’s
data-senna-track
attribute. Follow these steps to customize your resources:
-
Select the resource you want to modify the default behavior for.
-
Add the
data-senna-track
attribute to the resource. -
Set the
data-senna-track
attribute topermanent
to prevent a resource from unloading on navigation.Alternatively, set the
data-senna-track
attribute totemporary
to unload the resource on navigation.
The example below ensures that the JS resource isn’t unloaded during navigation:
<script src="myscript.js" data-senna-track="permanent" />
Great! Now you know how to specify how resources are loaded during SPA navigation.