+ Start a Discussion
David PicksleyDavid Picksley 

'Unload' static resource stylesheets when closing the component it is called from

We have a custom lightning component that takes advantage of an external stylesheet (stored in the static resources).

It is included with 
<ltng:require styles="{! $Resource.STYLESHEETNAMEHERE}"/>

My thinking is that the developer adds a sort of 'onExit' handler to unlink the file, but I can't find any documentation for unloading a static resource, or I could be completely wrong and it just be a caching issue

The issue is that some of the styles in that external resource are being carried over to other components that don't explicitly include the file
How can we tackle this?

A screen recording of the issue
  • Open a default modal (FINE)
  • Open a custom component that includes the CSS file named 'fullModalBypass.css'
  • Re-open the first modal, the modal contains the CSS file that was included in the component of the previous step
Best Answer chosen by David Picksley
Naveen KNNaveen KN
Hi David, I don't think we can unload the static resource from the DOM once it is loaded. try to see if you can do something in the renderer js file in the lightning component bundle.