An Empirical Study on the Use of CSS Preprocessors

Cascading Style Sheets (CSS) is the standard language for styling structured documents, such as HTML. However, CSS lacks most of the traditional programming constructs, including variables and functions, which enable code reuse and structured programming. Alternatively, CSS Preprocessors (e.g., LESS, SASS) have been introduced as superset languages to extend CSS by supporting those missing constructs. While these languages are being widely used by developers, we do not have sufficient knowledge about how developers take advantage of the features they provide. Gaining this knowledge is crucial for providing better tool support to the developer community by devising techniques for the automatic migration of existing CSS code to take advantage of CSS Preprocessor language features, designing refactoring recommendation systems for existing Preprocessor code, and giving insights to the Preprocessor language designers for improving language usability. In this paper, we have empirically investigated the CSS Preprocessor codebase of 150 websites regarding four preprocessor features, namely variables, nested selectors, mixins and extend constructs, and report the discovered usage patterns for each feature. We also discuss how the gained knowledge can be put into practice towards improving the development and maintenance of CSS preprocessor code.

[1]  Ali Mesbah,et al.  Discovering refactoring opportunities in cascading style sheets , 2014, SIGSOFT FSE.

[2]  Michael D. Ernst,et al.  An Empirical Analysis of C Preprocessor Use , 2002, IEEE Trans. Software Eng..

[3]  Hakon Wium Lie,et al.  Cascading Style Sheets: Designing for the Web , 1997 .

[4]  Jan Vitek,et al.  An analysis of the dynamic behavior of JavaScript programs , 2010, PLDI '10.

[5]  Ewan D. Tempero,et al.  How Do Java Programs Use Inheritance? An Empirical Study of Inheritance in Java Software , 2008, ECOOP.

[6]  Carlo Ghezzi,et al.  An empirical investigation into a large-scale Java open source code repository , 2010, ESEM '10.

[7]  Matthias Keller,et al.  CSS Code Quality: A Metric for Abstractness; Or Why Humans Beat Machines in CSS Coding , 2010, 2010 Seventh International Conference on the Quality of Information and Communications Technology.

[8]  Qinbao Song,et al.  An analysis of programming language statement frequency in C, C++, and Java source code , 2015, Softw. Pract. Exp..

[9]  Hridesh Rajan,et al.  Mining billions of AST nodes to study actual and potential usage of Java language features , 2014, ICSE.

[10]  Pierre Genevès,et al.  Automated refactoring for size reduction of CSS style sheets , 2014, DocEng '14.

[11]  Joseph Gil,et al.  The Use of Overloading in Java Programs , 2010, ECOOP.

[12]  Steven Pemberton,et al.  Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification , 2010 .

[13]  Giuliano Antoniol,et al.  Make It Simple - An Empirical Analysis of GNU Make Feature Use in Open Source Projects , 2015, 2015 IEEE 23rd International Conference on Program Comprehension.

[14]  Romain Robbes,et al.  How developers use the dynamic features of programming languages: the case of smalltalk , 2011, MSR '11.

[15]  Vincent Quint,et al.  On the analysis of cascading style sheets , 2012, WWW.

[16]  Ali Mesbah,et al.  Automated analysis of CSS rules to support style maintenance , 2012, 2012 34th International Conference on Software Engineering (ICSE).

[17]  Manuel Serrano HSS: a compiler for cascading style sheets , 2010, PPDP.