-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to unload CSS dynamically (before loading new) #3
Comments
For now I managed to implement a workaround where I remove the $('link[href="' + oldBootstrapThemeCss + '"]').remove(); Perhaps a more robust solution can be found, if I have time I will try to see if I could extend the code. ThoughtI browsed the existing code and see that the CSS is always loaded in an ID with a unique ID using function By using the same ID on reload instead I think the old stylesheet wil be automatically unloaded. For this I would propose an extension of the loader plugin syntax of The Alternatively having an empty <link href="path/css-file.css" id="css-file" One reason for this extended @-syntax is that I would actually like to have a similar loader for HTML content (e.g. a |
In Removing or replacing a stylesheet (a <link>) with JavaScript/jQuery - Stack Overflow the question says:
The answer says:
Check out that answer. So appart from the obvious cross-browser issues, you also need to consider at least this: There is a limit on how many style sheets you can have on a page. Will navigating back-and-forth repeatedly trigger this limit? Will removing one sheet and then adding a new one increase the sheet count? Then you've got a problem. However, there is perhaps a better approach: twitter bootstrap - How to dynamically change themes after clicking a drop down menu of themes - Stack Overflow basically suggests:
See it in action. |
Is there anyway to unload a loaded CSS with this package?
This would allow dynamically changing the CSS, for instance based on user input.
I notice on a HTML control/component that I am dynamically loading uses this
css
loader plugin, that on requiring/loading other .css files later, the styles seems to become 'stacked'. By that I mean that earlier styles are not removed again, only the new .css is put on top of it.See this screenshot for an explanation. It shows that the order in which .css'es are loaded is of importance, while in my case I want them to be mutually exclusive, i.e. unload old CSS first before loading new (I'm using bootstrap themes).
The text was updated successfully, but these errors were encountered: