Reasoning with Style

The Cascading Style Sheets (CSS) language constitutes a key component of web applications. It offers a series of sophisticated features to stylize web pages. Its apparent simplicity and power are however counter-balanced by the difficulty of debugging and maintaining style sheets, tasks for which developers still lack appropriate tools. In particular, significant portions of CSS code become either useless or redundant, and tend to accumulate over time. The situation becomes even worse as more complex features are added to the CSS language (e.g. CSS3 powerful selectors). A direct consequence is a waste of CPU that is required to display web pages, as well as the significant amount of useless traffic at web scale. Style sheets are designed to operate on a set of documents (possibly generated). However, existing techniques consist in syntax validators, optimizers and runtime debuggers that operate in one particular document instance. As such, they do not provide guarantees concerning all web pages in CSS refactoring, such as preservation of the formatting. This is partly because they are essentially syntactic and do not take advantage of CSS semantics to detect redundancies. We propose a set of automated refactoring techniques aimed at removing redundant and inaccessible declarations and rules, without affecting the layout of any document to which the style sheet is applied. We implemented a prototype that has been extensively tested with popular web sites (such as Google Sites, CNN, Apple, etc.). We show that significant size reduction can be obtained while preserving the code readability and improving maintainability.

[1]  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.

[2]  Luciano Baresi,et al.  Proceedings of the 2013 9th Joint Meeting on Foundations of Software Engineering , 2013, FSE 2013.

[3]  Nils Gesbert,et al.  Efficiently Deciding μ-Calculus with Converse over Finite Trees , 2015, ACM Trans. Comput. Log..

[4]  Mike Y. Chen,et al.  SeeSS: seeing what i broke -- visualizing change impact of cascading style sheets (css) , 2013, UIST.

[5]  Leo A. Meyerovich,et al.  Fast and parallel webpage layout , 2010, WWW '10.

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

[7]  Ethan V. Munson,et al.  Today's Style Sheet Standards: The Gread Vision Blinded , 1999, Computer.

[8]  Vincent Quint,et al.  Editing with style , 2007, DocEng '07.

[9]  Edward Benson,et al.  Mockup driven web development , 2013, WWW.

[10]  David R. Karger,et al.  Cascading tree sheets and recombinant HTML: better encapsulation and retargeting of web content , 2013, WWW.

[11]  Eugene Agichtein,et al.  Proceedings of the 26th International Conference on World Wide Web Companion , 2017, WWW 2017.

[12]  Simone Marinai,et al.  Proceedings of the 2013 ACM symposium on Document engineering , 2013, DocEng 2013.

[13]  Juliana Freire,et al.  Proceedings of the 19th international conference on World wide web , 2010, WWW 2010.

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

[15]  Nishant Sinha,et al.  Compiling mockups to flexible UIs , 2013, ESEC/FSE 2013.

[16]  Matthias Keller,et al.  Cascading style sheets: a novel approach towards productive styling with today's standards , 2009, WWW '09.

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

[18]  Pierre Genevès,et al.  Efficient static analysis of XML paths and types , 2007, PLDI '07.