Davood Mazinanian, Nikolaos Tsantalis Concordia University, Montreal CSER FALL 2013 MEETING 1 An Empirical Study of Duplication in Cascading Style Sheets.

Slides:



Advertisements
Similar presentations
CSS Cascading Style Sheets. Contents{ 1. What is CSS? 1. A Brief History of CSS 2. Why to use Styles? 2. Syntax 3. Cascading Order 4. Examples of Properties.
Advertisements

Web Pages Week 10 This week: CSS Next week: CSS – Part 2.
Cascading Style Sheets
Today CSS HTML A project.
Chapter 3 – Designing your web pages Dr. Stephanos Mavromoustakos.
Discovering Refactoring Opportunities in Cascading Style Sheets Davood Mazinanian Nikolaos Tsantalis Ali Mesbah Concordia University, Montréal, Canada.
Introduction to CSS.
Cascading Style Sheets Based on Castro, HTML for the WWW, 6 th edition Ron Gerton, Fall 2007.
Web Pages and Style Sheets Bert Wachsmuth. HTML versus XHTML XHTML is a stricter version of HTML: HTML + stricter rules = XHTML. XHTML Rule violations:
An empirical study on the use of CSS Preprocessors Davood Mazinanian - Nikolaos Tsantalis Department of Computer Science and Software Engineering Concordia.
Tutorial 3 Introducing Cascading Style Sheets. XP New Perspectives on Blended HTML, XHTML, and CSS2 Objectives Learn about Cascading Style Sheets Write.
Chapter 6 Web Typography
Introduction to Cascading Style Sheets (CSS) Module 2: HTML Basics LESSON 4.
Instructional Technology & Design Office or Insert Workshop Name Presented by Your Name Here.
Beginning Web Site Creation: Dreamweaver CS4. XHTMLCSS  Describes the structure  Content  Collection of styles  Formatting body { background-color:
XHTML and CSS Overview. Hypertext Markup Language A set of markup tags and associated syntax rules Unlike a programming language, you cannot describe.
1 Dynamic HTML and Cascading Style Sheets (CSS) Dynamic HTML and Cascading Style Sheets (CSS) Electronic Commerce Prof. Sheizaf Rafaeli.
CM143 Week 4 Introducing CSS. Cascading Style Sheets A definition for the style in which an element of the webpage will be displayed Border width, colour,
Tutorial 3: Adding and Formatting Text. 2 Objectives Session 3.1 Type text into a page Copy text from a document and paste it into a page Check for spelling.
Using Cascading Style Sheets (CSS) Dept. of Computer Science and Computer Information CSCI N-100.
Technologies for web publishing Ing. Václav Freylich Lecture 5.
 Using Microsoft Expression Web you can: › Create Web pages and Web sites › Set what you site will look like as you design it › Add text, images, multimedia.
Cascading Style Sheet. What is CSS? CSS stands for Cascading Style Sheets. CSS are a series of instruction that specify how markup elements should appear.
DHTML. What is DHTML?  DHTML is the combination of several built-in browser features in fourth generation browsers that enable a web page to be more.
Principles of Web Design 6 th Edition Chapter 4 – Cascading Style Sheets.
Chapter 4 Cascading Style Sheets Basics Key Concepts Copyright © 2013 Terry Ann Morris, Ed.D 1.
Chapter 11 Cascading Style Sheets: Part I The Web Warrior Guide to Web Design Technologies.
HTML - Quiz #2 Attendance CODE:
Cascading style sheets (CSS)
The Characteristics of CSS
CSS Cascading Style Sheets By Garrett Garman. CSS Why use Style Sheets? Separates Appearance and Structure Modularity Quick and Easy changes Flexibility.
Today’s objectives  Complete web page  Using xhtml & CSS  Adding CSS to documents Embed url(File);  CSS.
INTRODUCTION TO HTML5 CSS Styles. Understanding Style Sheets  HTML5 enables you to define many different types of content on a web page, including headings,
Chapter 6 Web Typography. 2 Principles of Web Design Chapter 5 Objectives Understand principles for type design on a Web site Use the element Understand.
Chapter 12 Cascading Style Sheets: Part II The Web Warrior Guide to Web Design Technologies.
1 What is CSS?  CSS stands for Cascading Style Sheets  Styles define how to display HTML elements  Styles are normally stored in Style Sheets  Styles.
WRT235: Writing in Electronic Environments Basic CSS.
CSS. HTML: Looking Back HTML dictates order, structure, and function Does very little to specify layout or visual rendering.
MySQL and PHP Review CSS. Cascading Style Sheet (CSS) Style sheets are files or forms that describe the layout and appearance of a document. Cascading.
CS134 Web Design & Development Cascading Style Sheets (CSS) Mehmud Abliz.
Css. Definition Cascading style sheet (CSS)  It is a simple mechanism for adding style (e.g. fonts, colors, spacing) to Web documents.
Instructional Technology & Design Office or Beginning Web Design Presented by Laura Miller.
HTML - Quiz #2 Attendance CODE:
CSS WORKSHOP Design Principles for Web Standards.
A really fairly simple guide to: mobile browser-based application development (part 2, CSS) Chris Greenhalgh G54UBI / Chris Greenhalgh
SASS & LESS Syntactically Awesome StyleSheets Dynamic StyleSheet Language Svetlin Nakov Technical Trainer Software University
HTML GUIDE Press F5 and then Click on the links on the left to get to the section you want Section 1: Getting Started Section 2: Moving Banner Section.
1 © Netskills Quality Internet Training, University of Newcastle Using Style Sheets in Dreamweaver CS © Netskills, Quality Internet Training, University.
Cascading Style Sheets Eugenia Fernandez IUPUI. CSS Purpose CSS allow you to specify the style in which your XML elements are displayed. CSS were originally.
Introduction to CSS. Why CSS? CSS Provides Efficiency in Design and Updates CSS relatively easy to use Can give you more flexibility and control Faster.
CSS Cascading Style Sheets A very brief introduction CSS, Cascading Style Sheets1.
5 th ed: Chapter 4 4 th ed: Chapter 5 SY306 Web and Databases for Cyber Operations Slide Set #4: CSS.
Microsoft Expression Web 3 – Illustrated Unit D: Structuring and Styling Text.
CSS Hadas Kahsay. Overview  What is CSS  Basic syntax of CSS Rules  How to link CSS style to html documents  Browsers and CSS  Advantages of CSS.
Cascading Style Sheets Primary readings Presentations Explain & review projects with class mates.
Web Technologies Beginning Cascading Style Sheets (CSS) 1Copyright © Texas Education Agency, All rights reserved.
CSS Table Styling. Up to this point, as we haven't applied any CSS styling to our tables, our example tables have not been too pleasing to the eye. CSS.
NASRULLAHIBA.  It is time to take your web designing skills to the next level with Cascading Style Sheets (CSS). They are a way to control the look and.
Understanding CSS Cascading Style Sheets control the presentation of content in HTML pages Style Sheets separate formatting from the content –Styles defined.
Blended HTML and CSS Fundamentals 3 rd EDITION Tutorial 3 Introducing Cascading Style Sheets.
What is CSS? A set of style rules that tell the web browser how to present a web page or document. – In earlier versions of HTML, style characteristics,
Cascading Style Sheets Using HTML. What are they? A set of style rules that tell the web browser how to present a web page or document. In earlier versions.
CSS Introductions. Objectives To take control of the appearance of a Web site by creating style sheets. To use a style sheet to give all the pages of.
An empirical study on the use of CSS Preprocessors Davood Mazinanian Nikolaos Tsantalis Department of Computer Science and Software Engineering Concordia.
Chapter 3 Designing Your Web Pages. Objectives What is CSS and Why it is needed How CSS looks and how to write it The different ways to add CSS code to.
CSS.
Migrating CSS to Preprocessors by Introducing Mixins
CSS Borders and Margins.
What are Cascading Stylesheets (CSS)?
Presentation transcript:

Davood Mazinanian, Nikolaos Tsantalis Concordia University, Montreal CSER FALL 2013 MEETING 1 An Empirical Study of Duplication in Cascading Style Sheets

Outline CSS: characteristics, syntax, usage Three types of duplication in CSS Detection of duplication in CSS Results of the empirical study Conclusions and future works CSER FALL 2013 MEETING 2

What's CSS Definition ◦CSS is a domain specific language: ◦A styling language ◦CSS level 1 Recommendation was published in 1996 by W3C ◦It enabled the separation of concerns for the web ◦It made responsive design easy ◦By supporting different media types (screen, printer, handheld, etc) ◦And media queries in CSS3 CSER FALL 2013 MEETING 3

Exploiting CSS Pure CSS + HTML CSER FALL 2013 MEETING 4

CSS is widely used… 90 percent of web developers use CSS [w3techs.com, Mozilla survey] Large number of CSS contributors in open source world [ohloh.net] CSER FALL 2013 MEETING 5 Mozilla survey results: What programming language do you use?

Syntax No variables or functions… ◦So we may have duplication in value, declaration and selector level CSER FALL 2013 MEETING 6

CSS Development Developers use server side languages (like PHP) or preprocessors ◦Easy CSS generation using variables and functions ◦SASS, LESS, Google Closure Stylesheets, etc. ◦They have their own syntax ◦But the generated CSS files still have significant duplication CSER FALL 2013 MEETING + #111); #header { } #header { color: #6c94be; } LESS CSS

CSS Tools Static validators ◦W3C validator Removing unused CSS ◦Tools (dust-me-selectors Firefox add-on, etc.) ◦Academic papers (CILLA, Tree logics) Removing duplication ◦Tools (CSSCSS, CSS purge, etc.) ◦They support trivial types of duplication! CSS maintenance cannot be considered as a disciplined and systematic practice. CSER FALL 2013 MEETING 8

Our goal Short term ◦Detect non-trivial duplications in the CSS files ◦And eventually refactor them Long term ◦Improve the state of the art of the CSS maintenance CSER FALL 2013 MEETING 9

Our motivation Why duplication in CSS is bad? ◦Maintenance ◦In the case of changes due to new requirements, all instances off duplicated code should be found and updated ◦Inconsistent updates lead to inconsistent presentation ◦Efficiency ◦Waste of bandwidth and slower download / upload time ◦Increased computation cost for the processing of CSS files by web browsers CSER FALL 2013 MEETING 10

Types of duplications We defined Three types of declaration duplication CSER FALL 2013 MEETING 11

TYPE I Gmail’s main CSS file had more than LOC, when formatted There are 23 repeated declarations for three different selectors! Declarations with the lexically same property and values. CSER FALL 2013 MEETING 12.z-b-ua { /* */ … color: #fff; cursor: default; font-size: 11px; font-weight: bold; text-align: center; white-space: nowrap; border: 1px solid transparent; border-radius: 2px; … transition-duration:.218s; ….z-b-ga { /* */ … color: #fff; cursor: default; font-size: 11px; font-weight: bold; text-align: center; white-space: nowrap; border: 1px solid transparent; border-radius: 2px; … transition-duration:.218s; …

TYPE II Declarations with the: Same properties with equivalent values Or same properties with missing default values that are implied. CSER FALL 2013 MEETING 13.c-i { /* */ … -webkit-transition: opacity.218s; transition: opacity.218s; … }.kz { /* */ … -webkit-transition: opacity.218s ease; transition: opacity.218s ease }.iF9mle { /* 8742 */ … background: white; … }.c-S-aa { /* */ … background: #fff; … }

TYPE III Set of individual declarations, and the equivalent shorthand declaration in another selector CSER FALL 2013 MEETING 14.qfacj { /* 8723 */ … border-style: solid; border-width: 1px; border-color: #ccc; … }.c-i { /* */ … border: 1px solid #ccc; … } Individual declarations Shorthand declaration

Method Parsing CSS ◦We enhanced Flute CSS parser (from W3C) to comply with CSS3 ◦Parse CSS to a simple but effective model ◦Detect duplications from it, ◦Map it to the HTML document ◦Refactor the CSS using it (in the future) ◦Format CSS code using it, ◦Compare Stylesheets ◦And many more… CSER FALL 2013 MEETING 15

Method Preprocessing of declarations ◦For type II ◦Replacing all values which have different representation with reference values ◦For type III ◦Creating new shorthand declarations for individual declarations (virtual shorthand declarations) Detection ◦Pairwise comparison of all declarations in the model, considering order of values CSER FALL 2013 MEETING 16

Grouped selectors It is possible for two or more selectors to have more than one declaration in common. In these cases we might be able to use CSS grouping to eliminate duplication CSER FALL 2013 MEETING 17.Selector_A { color: #fff; cursor: default; font-size: 11px; font-weight: bold; }.Selector_B { color: #fff; cursor: default; font-size: 11px; font-weight: bold; }.Selector_A,.Selector_B { color: #fff; cursor: default; font-size: 11px; font-weight: bold; }

Data mining metaphor Lets consider: ◦CSS file is a transaction database, ◦Every selector is a transaction, ◦Every declaration is an item CSER FALL 2013 MEETING 18.Selector_A { color: #fff; cursor: default; font-size: 11px; }.Selector_B { color: #fff; font-size: 11px; font-weight: bold; } Transaction IDItems Selector_A color: #fff; cursor: default; font-size: 11px; Selector_B color: #fff; font-size: 11px; font-weight: bold;

Frequent Itemset generation CSER FALL 2013 MEETING 19 Applying the first phase in association rule mining ◦Generate every set of items (declarations) which appear together in more than a specific number (the support count) of transactions (selectors) ◦We are interested in the group of declarations which appear in at least 2 selectors

Frequent itemset generation CSER FALL 2013 MEETING 20 Transaction ID Items.Selector_A color: #fff; cursor: default; font-size: 11px;.Selector_B color: #fff; font-size: 11px; font-weight: bold;.Selector_A { color: #fff; cursor: default; font-size: 11px; }.Selector_B { color: #fff; font-size: 11px; font-weight: bold; } Frequent ItemsetSupport { color: #fff, font-size: 11px; }.Selector_A,.Selector_B

Frequent itemset generation 1.Apriori algorithm ◦Generates every possible combination of items ◦For every combination, checks the database to see whether it is frequent 2.Eclat algorithm ◦It is using previous results to compute the support count of new itemsets ◦Eclat and Apriori may lead to combinatorial explosion, due to the low support count (2) ◦Gmail is an example (3 selectors had 23 declarations in common) 3.FP-Growth algorithm ◦Creates a tree, in which the nodes are items and paths represent all itemsets along with their frequency ◦Uses the tree to compute frequent itemsets ◦Doesn’t generate every possible combination of items in the search space CSER FALL 2013 MEETING 21

Empirical Study Data: ◦199 CSS files from 28 Open source web systems ◦Mostly content management systems ◦183 CSS files collected from top websites ◦from top 50 Alexa websites ◦Using Crawljax CSER FALL 2013 MEETING 22

Duplication at declaration level CSER FALL 2013 MEETING 23 About 60% of declarations are duplicated

Largest duplications CSER FALL 2013 MEETING 24 The median of the largest number of common declarations is 5 and 7 respectively

Largest duplications CSER FALL 2013 MEETING 25 The majority of duplication is between two selectors. There is also duplication between selectors Outliers were deleted when creating this figure

Grouping adoption CSER FALL 2013 MEETING 26 In average, less than 20% of all selectors of today’s CSS are grouped selectors. Open Source Extracted by Crawler

Size and duplication CSER FALL 2013 MEETING 27 Spearman test of correlation between size and duplicated declaration ratio Rhop-value Crawler- Extracted e-08 Open Source e-10

Grouping and duplication CSER FALL 2013 MEETING 28 Spearman test of correlation between grouping and duplicated declaration ratio Rhop-value Extracted by Crawler Open Source Open SourceExtracted by Crawler

Conclusion and Future Works CSS is widely used, but there is a limited research on it Declarations of today’s CSS are about 60 percent duplicated in average You can find two or more selectors in a CSS file which have more than 5 shared declarations In average There is not a strong correlation between size and grouping ratio with the ratio of the duplicated declarations in CSS files We may: ◦Refactor these duplications ◦using grouping in CSS, creating classes, or taking advantage of the hierarchy of DOM elements ◦Use duplication info to migrate from CSS to preprocessors ◦An many more… CSER FALL 2013 MEETING 29

Thank You CSER FALL 2013 MEETING 30