Is there a $.getScript equivalent in jQuery, but for loading stylesheets?
Is there a $.getScript equivalent in jQuery, but for loading stylesheets?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
CSS is not a script, so you dont have to “execute” it in the sense of script execution.
Basically a
<link>tag created on the fly and appended to the header should suffice, likeor
if you want to do it without jQuery.
The browser will respond to the change in the DOM and update your page layout accordingly.
EDIT:
I have read that old Internet Explorer has trouble with this, and you might need to do it like in answer to make it work:
https://stackoverflow.com/a/2685639/618206
EDIT2:
Reading the file content and putting it inline (between
<style>tags) is also a valid solution, but that way the CSS will not be cached by the browser.