0

In my application, I load a CSS files in the back-end (using Express.JS) and load it in the frontend. However, before sending CSS code to the front-end application, I want to:

  • Detect the user's browser;
  • Edit the CSS code accordingly.

For example, if user A uses Chrome, remove all lines that start with -webkit-.

How can I detect the browser and edit the CSS code with the best performance?

Note: My CSS code is formatted as beautified and not minified.

1
  • Can you explain the reason of doing this? gziping your css files before sending to browser will be faster and more effective Commented Nov 21, 2016 at 7:11

1 Answer 1

-1

We can detect User's browser by using user agents. Here is the URL to the answer regarding how to detect user agent.

Now, unless changing content of your CSS file, make 2 different files for different browser types and write some condition on your page CSS link tag accordingly.

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

2 Comments

I can detect user browser agent but I want to edit the CSS code accordingly that I explained.
You know one thing, editing CSS on the go will make a little delay in the response to the user. This is not recommended. Apart from that, the answer given by me is a suggestion and totally workable if you change the approach, so a negative vote is not justified.

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.