An empirical study on the use of CSS Preprocessors Davood Mazinanian - Nikolaos Tsantalis Department of Computer Science and Software Engineering Concordia.

Slides:



Advertisements
Similar presentations
Copyright © 2003 Pearson Education, Inc. Slide 3-1 Created by Cheryl M. Hughes The Web Wizards Guide to XML by Cheryl M. Hughes.
Advertisements

CSS Basics Style and format your web site using CSS.
Web Pages Week 10 This week: CSS Next week: CSS – Part 2.
CSCI 3100 Tutorial 6 Web Development Tools 1 Cuiyun GAO 1.
Cascading Style Sheets
Programming Club IIT Kanpur. Work environment Before you begin coding,always set up your work environment to your needs IDE Notepad++ Sublime Text 2.
UNDERSTANDING CSS: THINKING INSIDE THE BOX The Cottage Garden The cottage garden is a distinct style of garden that uses an informal design, dense planting.
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.
Cascading Style Sheets. CSS stands for Cascading Style Sheets and is a simple styling language which allows attaching style to HTML elements. CSS is a.
HyperText Markup Language (HTML) Uses plain text to add markup instructions to a file. If you can't produce it with a standard keyboard, it can't go into.
Cascading Style Sheets Basics. Why use Cascading Style Sheets? Allows you to set up a series of rules for all pages in a site. The series may be changed.
Principles of Web Design 5 th Edition Chapter Nine Site Navigation.
1 Web Developer & Design Foundations with XHTML Chapter 9 Key Concepts.
End User Computing An Introduction to CSS Sujana Jyothi Research Lab1, Callan Building, Department of Computer Science
CSS BASICS. CSS Rules Components of a CSS Rule  Selector: Part of the rule that targets an element to be styled  Declaration: Two or more parts: a.
1 Pengantar Teknologi Internet W03: CSS Cascading Style Sheets.
Recognizing the Benefits of Using CSS 1. The Evolution of CSS CSS was developed to standardize display information CSS was slow to be supported by browsers.
1 Dreamweaver CS5 intermediate class by Cookie Setton Build a CSS website WITHOUT TABLES Just when you thought you were starting to understand HTML coding,
Web Pages and Style Sheets Bert Wachsmuth. HTML versus XHTML XHTML is a stricter version of HTML: HTML + stricter rules = XHTML. XHTML Rule violations:
Diliev.com & pLOVEdiv.com  DIliev.com.
Cascade Style Sheet Demo. Cascading Style Sheets Cascading Style Sheets (CSS) is a simple mechanism for adding style (e.g., fonts, colors, spacing) to.
Robby Seitz 121 Powers Hall ADVANCED WEB DESIGN USING DREAMWEAVER
กระบวนวิชา CSS. What is CSS? CSS stands for Cascading Style Sheets Styles define how to display HTML elements Styles were added to HTML 4.0 to.
ADVANCED CSS William Neely CEO, Piecewise.com. CSS FONTS AND TEXT CSS ‣ Line-height allows to indicate the amount of space between lines; allows for equal.
Chapter 8 Creating Style Sheets.
Web Design with Cascading Style Sheet Lan Vu. Overview Introduction to CSS Designing CSS Using Visual Studio to create CSS Using template for web design.
Chapter 6 Web Typography
AD Intermediate Computer Graphics | spring 2008 | Daria Tsoupikova | School of Art and Design | UIC CSS Cascading Style Sheets.
XP 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
Dreamweaver -- CSS. Dreamweaver -- MX New icons are added in MX Most of the features commonly used in web design, and are same as FrontPage. New feature.
Using Styles and Style Sheets for Design
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.
Cascading Style Sheets. Defines the presentation of one or more web pages Similar to a template Can control the appearance of an entire web site giving.
CSS The Definitive Guide Chapter 8.  Allows one to define borders for  paragraphs  headings  divs  anchors  images  and more.
CHAPTER 1 HTML & HTML5 I อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา 1.
CSS Basic (cascading style sheets)
CS134 Web Design & Development Cascading Style Sheets (CSS) Mehmud Abliz.
Davood Mazinanian, Nikolaos Tsantalis Concordia University, Montreal CSER FALL 2013 MEETING 1 An Empirical Study of Duplication in Cascading Style Sheets.
Chapter 6 Introducing Cascading Style Sheets Principles of Web Design, 4 th Edition.
Advanced Web Development Instructor: Thomas Bombach.
SASS & LESS Syntactically Awesome StyleSheets Dynamic StyleSheet Language Svetlin Nakov Technical Trainer Software University
1 CSS-PREPROCESSORS as a way to speed up the process of interfaces developing and achieve Customer goals DMITRY SHURSHILIN AUGUST 3, 2015.
Cascading Style Sheets Level 2. Course Objectives, Session 1 Level 1 Quick Review Chapter 8: Adding Graphics to Web Pages Chapter 9: Sprucing Up Your.
Cascading Style Sheets (CSS). A style sheet is a document which describes the presentation semantics of a document written in a mark-up language such.
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.
Copyright © Osmosys O S M O S Y SO S M O S Y S D e p l o y i n g E x p e r i e n c e & E x p e r t i s e™ CSS Training.
 HTML, CSS, JavaScript – enormously successful  SASS has all the tools we need! INTRO.
IN THE DOCUMENT OBJECT MODEL, EACH LINE OF HTML IS AN ELEMENT (AN OBJECT), ABLE TO HAVE ATTRIBUTES, PROPERTIES AND VALUES. CSS TELLS THE BROWSER HOW TO.
Understanding CSS Cascading Style Sheets control the presentation of content in HTML pages Style Sheets separate formatting from the content –Styles defined.
>> CSS Layouts. Recall Properties of Box – Border (style, width, color) – Padding – Margin – Display – Background – Dimension Welcome Padding Area Border.
An empirical study on the use of CSS Preprocessors Davood Mazinanian Nikolaos Tsantalis Department of Computer Science and Software Engineering Concordia.
CSS.
Migrating CSS to Preprocessors by Introducing Mixins
Simple theme creation using Sass
The Box Model in CSS Web Design – Sec 4-8
Advanced Web Page Styling
Cascading Style Sheets (Layout)
>> CSS Layouts.
Cascading Style Sheets
CSS PreProcessors MIS 424.
Software Engineering for Internet Applications
: Clone Refactoring Davood Mazinanian Nikolaos Tsantalis Raphael Stein
Software Refactoring Group
CSS Styles Introduction.
Understand basic HTML and CSS terminology, concepts, and basic operations. Objective 3.01.
Cascading Style Sheets III B. Com (Paper - VI) & III B
Session IV Chapter 15 - How Work with Fonts and Printing
Presentation transcript:

An empirical study on the use of CSS Preprocessors Davood Mazinanian - Nikolaos Tsantalis Department of Computer Science and Software Engineering Concordia University - Montreal

Agenda Introduction to CSS and CSS preprocessors Motivation The main research question: How developers use CSS preprocessor features? 2 / 24

Cascading Style Sheets (CSS) The standard styling language Target documents Limitations of CSS Was initially designed for non-developers! Duplication is pervasive! selector { property: value; } IntroductionMotivationEmpirical Study 3 / 24 Declaration

CSS Preprocessors Super-language for CSS for generating CSS Adding missing features: Variables, functions, loops, conditional statements, mathematical operations, etc. IntroductionMotivationEmpirical Study 4 / 24

Motivation Credits: css-tricks.com/poll-results-popularity-of-css-preprocessors/ IntroductionMotivationEmpirical Study 5

Motivation Collecting information to: Support devising automatic migration techniques Support developing preprocessor refactoring approaches IntroductionMotivationEmpirical Study 6 / 24

Empirical Study Subjects 80 websites (40 websites for Less, 40 for Sass) 220 Less and 738 Sass files (total 958 files) Found preprocessor files using Google! E.g.: filetype:less Parse LESS SASS AST Query CSV files Analysis Results IntroductionMotivationEmpirical Study 7 / 24

Feature #1: Nesting Goals: better organization, avoiding duplication in selector names table { border: none; outline: 0; } table:hover { font-weight: bold; } table td { margin: 3px; } table { border: none; outline: 0; &:hover { font-weight: bold; } td { margin: 3px; } IntroductionMotivationEmpirical Study CSSPreprocessor 8 / 24

Feature #1: Nesting By far the most-used feature of CSS preprocessors! Out of all selectors, are nested, or have nested selectors (65%) Question: Are they used even for shallow nesting? IntroductionMotivationEmpirical Study 9 / 24

Feature #1: Nesting How deep was nesting? IntroductionMotivationEmpirical Study 10 / 24

Feature #1: Nesting Conclusions Every migration tool / technique should support “migration to nesting”! Developers nest selectors, even if the level of nesting is not very deep! IntroductionMotivationEmpirical Study 11 / 24

Feature #2: Mixins Goal: increasing re-usability and comprehensibility of code Preprocessor CSS table { margin: 5px;.border(1px, { border: black; outline: ridge } table { margin: 5px; border: solid 1px black; border-radius: 3px; outline: ridge black 0; } IntroductionMotivationEmpirical Study 12 / 24

Feature #2: Mixins Mixin calls: how much re-usability? IntroductionMotivationEmpirical Study 13 / 24

Feature #2: Mixins Size of Mixins 80% of Mixins have less than 5 declarations IntroductionMotivationEmpirical Study 14 / 24

Feature #2: Mixins Size of Mixins IntroductionMotivationEmpirical Study 15 / 24

Feature #2: Mixins Number of parameters IntroductionMotivationEmpirical Study 36% 25% 31%30% 16 / 24

Feature #2: Mixins Parameter re-use Mixins with parameters used in more than one type of declaration Sass: 13% Less: 18% # Parameters and # declarations inside Mixins are not correlated Spearman Rho = 0.17 with p-value = { } IntroductionMotivationEmpirical Study 17 / 24

Feature #2: Mixins 65% of Mixins are used for cross-browser 2px) { } IntroductionMotivationEmpirical Study 18 / 24

Feature #2: Mixins Conclusions Mixins having cross-browser declarations are preferred Perhaps because they have greater impact on minimizing duplication (to be researched) Mixins do not tend to have Large number of parameters Large number of declarations Thus, it is not preferred to have large Mixins with too many parameters IntroductionMotivationEmpirical Study 19 / 24

Feature #3: Extend Minimizing duplication by grouping selectors IntroductionMotivationEmpirical Study table { float: left; &:extend(.zeroSpacing) }.zeroSpacing { margin: 0; padding: 0; } table { float: left; }.zeroSpacing, table { margin: 0; padding: 0; } Preprocessor CSS 20 / 24

Feature #3: Extend Much less used than Mixins No usages in the Less dataset, Only 15% of Sass files had an Extend usage inside Reason: order dependencies Using Extend will change the order of the selectors that may lead to breaking the presentation IntroductionMotivationEmpirical Study 21 / 24

Feature #3: Extend Breaking the presentation by using Extend! IntroductionMotivationEmpirical Study table { float: left; &:extend(.zeroSpacing) } table { margin: 2px; }.zeroSpacing { margin: 0; padding: 0; } table { float: left; } table { margin: 2px; }.zeroSpacing, table { margin: 0; padding: 0; } Preprocessor CSS 22 / 24

Feature #3: Extend Conclusions Prefer to use Mixin instead of Extend Even though it may produce more duplication in the resulting file If removing duplication by using Extend, check the overriding dependencies! IntroductionMotivationEmpirical Study 23 / 24

Summary Using preprocessors is a trend! Developers use Nesting whenever possible! Mixins: Are short (less than 5 declarations), Mostly have zero or one parameters Are usually used for cross-browser declarations! Developers prefer using Mixins over Extends! It is not always safe to use Extend 24 / 24