Specifying How Resources Are Loaded During Navigation

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:

  1. Select the resource you want to modify the default behavior for.

  2. Add the data-senna-track attribute to the resource.

  3. Set the data-senna-track attribute to permanent to prevent a resource from unloading on navigation.

    Alternatively, set the data-senna-track attribute to temporary 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.

« Disabling SPADetaching Global Listeners »
Was this article helpful?
0 out of 0 found this helpful