I have been trying to import a css file using @import through javascript. I know there are other methods like createELement("link") through js but I need to import the css file instead of linking it, because I'm working on client site and their css is conflicting with mine. I can't set !important for all my css and thought @import css file has much higher preference than linked css file and its working.I just need to know how to import it using js.
Asked
Active
Viewed 197 times
1
-
Link the css in later than the conflicting css file. A terrible solution would be linking a css file that has that @import. – Jashwant Nov 09 '15 at 10:14
-
@Jashwant actually that terrible thing worked. linking the file which has the import statement is working. But is it a bad practice? – Chanikya Mohan Nov 09 '15 at 10:36
-
linking the higher preference file at the end of header also worked. Thanks @Jashwant – Chanikya Mohan Nov 09 '15 at 10:40
1 Answers
1
Javascript does not have @import .You can check this link for more information More about it
-
Okay, so is there any other way to link css so that the main website's css wont get conflicted with mine. – Chanikya Mohan Nov 09 '15 at 10:34
-