Default controls CSS styles are just great

6 posts, 0 answers
  1. Yve
    Yve avatar
    5 posts
    Member since:
    Jul 2014

    Posted 08 Aug 2014 Link to this post

    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.
  2. Yve
    Yve avatar
    5 posts
    Member since:
    Jul 2014

    Posted 08 Aug 2014 Link to this post

    Attached is an example of the brilliance.
  3. Yve
    Yve avatar
    5 posts
    Member since:
    Jul 2014

    Posted 09 Aug 2014 Link to this post

    Will this be improved in future releases?
  4. Marin Bratanov
    Admin
    Marin Bratanov avatar
    5616 posts

    Posted 12 Aug 2014 Link to this post

    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.

     
  5. Yve
    Yve avatar
    5 posts
    Member since:
    Jul 2014

    Posted 13 Aug 2014 in reply to Marin Bratanov Link to this post

    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!
  6. Ivan Zhekov
    Admin
    Ivan Zhekov avatar
    652 posts

    Posted 14 Aug 2014 Link to this post

    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.

     
Back to Top