1

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.

3
  • Link the css in later than the conflicting css file. A terrible solution would be linking a css file that has that @import. Commented 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? Commented Nov 9, 2015 at 10:36
  • linking the higher preference file at the end of header also worked. Thanks @Jashwant Commented Nov 9, 2015 at 10:40

1 Answer 1

1

Javascript does not have @import .You can check this link for more information More about it

Sign up to request clarification or add additional context in comments.

2 Comments

Okay, so is there any other way to link css so that the main website's css wont get conflicted with mine.
you can take a look at specificity in css

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.