This is a migrated thread and some comments may be shown as answers.
Default controls CSS styles are just great
5 Answers 12 Views
This is a migrated thread and some comments may be shown as answers.
Yve
Top achievements
Rank 1
Yve asked on 08 Aug 2014, 05:00 AM
Why are all the default controls css files so bloated?

You can remove at least 1/3 of it and keep it working EXACTLY the same way.

I think the person responsible for CSS for WebFroms controls should be fired. No. First sent back to school, then fired.

5 Answers, 1 is accepted

Sort by
0
Yve
Top achievements
Rank 1
answered on 08 Aug 2014, 05:02 AM
Attached is an example of the brilliance.
0
Yve
Top achievements
Rank 1
answered on 09 Aug 2014, 07:53 AM
Will this be improved in future releases?
0
Marin Bratanov
Telerik team
answered on 12 Aug 2014, 10:57 AM

Hello Yve,

While some of the stylesheets may seem redundant, there is a reason for most of the code you will find there. Let me iterate a few, most common, situations that may require such code:

  • A control must be able to work together in a myriad of cases. For the concrete case, inputs must have their own rules even if, for example, RadFormDecorator changes all other "regular" inputs on the page. Thus, they need to have their own selectors made heavier.
  • We still have to support old IE versions and they require a lot of CSS hacks to get things to look as expected. While they may not be needed in modern browsers, we still have many corporate clients that have to stick to old browsers and we cannot remove all of those CSS rules, even though we would also like to.
  • In some cases the legacy reasons for such code may have disappeared (e.g., support for IE6), yet we still cannot remove all of it because it will be 1) a breaking change and 2) it is usually more important to add new features and controls than reduce a few bytes off an old control that works as expected. This is a direct consequence of the common principle known as "don't fix it if it is not broken".

That being said, we are taking measures to reduce unnecessary CSS as much as possible:

  • We are creating more and more lightweight controls that have less CSS and images because they do not focus on old IE versions. Thus, I suggest you give that a try.
  • We are constantly trying to improve and reduce the current code and new features/controls are as optimized as possible.
  • We intend to improve existing code as soon as we can.

I hope this explains the situation.


Regards,

Marin Bratanov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Yve
Top achievements
Rank 1
answered on 14 Aug 2014, 04:35 AM
Hi Marin,

Thanks for your reply. Your reasoning is of course understandable, however I don't think that you addressed the particular case I posted a screenshot.

I certainly can understand extra code to support older browsers, but sometimes unnecessary bloat is just what it is - unnecessary bloat. Could you please justify the need for "html body" before each rule declaration?

Thanks in advance!
0
Ivan Zhekov
Telerik team
answered on 14 Aug 2014, 06:41 AM
Hi.

The way CSS works is by specifying rules with different specificity depending how important styles are. That allows for cascading and extending.

Element selectors e.g. html, body are the weakest and we use them when we need a tad stronger (more specific) selector. If we were to use class name it would be harder to overwrite.

Since some of the selectors cascade into different places it does happen that styles from one control would cascade to others. At times we use a tad stronger selectors, but if we need to overwrite those we need another tad stronger. Hence the html body in the beginning of the selectors.

Ideally, those will not be there, but it's a very very long process.

Regards,
Ivan Zhekov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Asked by
Yve
Top achievements
Rank 1
Answers by
Yve
Top achievements
Rank 1
Marin Bratanov
Telerik team
Ivan Zhekov
Telerik team
Share this question
or