ocLazyLoad
ocLazyLoad copied to clipboard
Is it possible to unload a resource?
Hello! Thanks for this module!
I have a question.
Is it possible to unload a specific resource?
I have two parts of my application that are using two different conflicting stylesheets. I want to use ocLazyLoad
to load CSS dynamically by the router for each of these two routes. I will need a way to remove loaded stylesheet when navigating from one route to the other.
Please advise. Thanks!
Hi, there is currently no way to unload something that has been loaded. It would be pointless with angular code because it wouldn't unload the components anyway.
For css it would work if you removed the link tag, but there is no way to do it in ocLazyLoad. You could search for the link tag and remove it yourself with something like that:
$('link[href="/url/to/your/file.css"]').remove();
Thank you @ocombe for your quick response!
Could you mark this issue as a feature request then?
Sure, but it would be for css / templates only
That is perfectly fine. I'm not sure that such a function can be useful for AngularJS modules.
For css this would be a real killer feature.
you can't remove resources after they've been loaded. jquery and angular can't fix this problem. browser manufacturers would have solved this a long time ago if it were that simple.
@curlyfro that is true for JavaScript not CSS. Stylesheets can be disabled via disable attribute or removed and the page will no longer utilize those styles.
My recommendation on this is to not manage stylesheets directly in ocLazyLoad but use a ng-switch at the top of your body tag.
anything new on this?