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.
-
Link the css in later than the conflicting css file. A terrible solution would be linking a css file that has that @import.Jashwant– Jashwant2015-11-09 10:14:26 +00:00Commented Nov 9, 2015 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– Chanikya Mohan2015-11-09 10:36:04 +00:00Commented Nov 9, 2015 at 10:36
-
linking the higher preference file at the end of header also worked. Thanks @JashwantChanikya Mohan– Chanikya Mohan2015-11-09 10:40:56 +00:00Commented Nov 9, 2015 at 10:40
Add a comment
|
1 Answer
Javascript does not have @import .You can check this link for more information More about it
2 Comments
Chanikya Mohan
Okay, so is there any other way to link css so that the main website's css wont get conflicted with mine.
brk
you can take a look at specificity in css