SlideShare une entreprise Scribd logo
1  sur  30
An Empirical Study of Duplication in
Cascading Style Sheets
D avo o d M a z i n a n i a n , N i ko l a o s Ts a n t a l i s
C o n c o rd i a U n ive r s i t y, M o n t re a l

CSER FALL 2013 MEETING

1
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]
100%
90%
80%
70%
60%
50%
40%
30%
20%
10%
0%

Mozilla survey results: What programming language do you use?
CSER FALL 2013 MEETING

5
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
@nice-blue: #5B83AD;
@light-blue: (@nice-blue + #111);
#header { color: @light-blue; }

#header { color: #6c94be; }
CSS

LESS

◦ But the generated CSS files still have significant duplication

CSER FALL 2013 MEETING

7
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
Gmail’s main CSS file had more than 18000
LOC, when formatted

TYPE I
Declarations with
the lexically same
property and
values.

There are 23 repeated declarations for three
different selectors!
.z-b-ua { /* 17972 */
.z-b-ga { /* 16871 */
…
…
color: #fff;
color: #fff;
cursor: default;
cursor: default;
font-size: 11px;
font-size: 11px;
font-weight: bold;
font-weight: bold;
text-align: center;
text-align: center;
white-space: nowrap;
white-space: nowrap;
border: 1px solid
border: 1px solid
transparent;
transparent;
border-radius: 2px;
border-radius: 2px;
…
…
transition-duration: .218s;
transition-duration: .218s;
…
…
CSER FALL 2013 MEETING

12
.iF9mle { /* 8742 */
…
background: white;
…
}

TYPE II
Declarations with
the:
• Same properties
with equivalent
values
• Or same
properties with
missing default
values that are
implied.

.c-S-aa { /* 14120 */
…
background: #fff;
…
}

.c-i { /* 18213 */
…
-webkit-transition: opacity .218s;
transition: opacity .218s;
…
}
.kz { /* 10691 */
…
-webkit-transition: opacity .218s ease;
transition: opacity .218s ease
}
CSER FALL 2013 MEETING

13
TYPE III
Set of individual
declarations, and
the equivalent
shorthand
declaration in
another selector

.qfacj { /* 8723 */
…
border-style: solid;
border-width: 1px;
border-color: #ccc;
…
}

Individual declarations

.c-i { /* 18213 */
…
border: 1px solid #ccc;
…
}

Shorthand declaration

CSER FALL 2013 MEETING

14
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
.Selector_A {
color: #fff;
cursor: default;
font-size: 11px;
font-weight: bold;
}

.Selector_A, .Selector_B {
color: #fff;
cursor: default;
font-size: 11px;
font-weight: bold;
}

.Selector_B {
color: #fff;
cursor: default;
font-size: 11px;
font-weight: bold;
}

CSER FALL 2013 MEETING

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

Transaction ID

Items

Selector_A

color: #fff;
cursor: default;
font-size: 11px;

Selector_B

color: #fff;
font-size: 11px;
font-weight: bold;

CSER FALL 2013 MEETING

18
Frequent Itemset generation
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

CSER FALL 2013 MEETING

19
Frequent itemset generation
.Selector_A {
color: #fff;
cursor: default;
font-size: 11px;
}

Transaction
ID

Items

.Selector_A
.Selector_B {
color: #fff;
font-size: 11px;
font-weight: bold;
}

color: #fff;
cursor: default;
font-size: 11px;

.Selector_B

color: #fff;
font-size: 11px;
font-weight: bold;

Frequent Itemset
{ color: #fff, font-size: 11px; }

CSER FALL 2013 MEETING

Support
.Selector_A, .Selector_B

20
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

About 60% of declarations are
duplicated

CSER FALL 2013 MEETING

23
Largest duplications

The median of the largest
number of common
declarations is 5 and 7
respectively

CSER FALL 2013 MEETING

24
Largest duplications

•
•
•

The majority of duplication
is between two selectors.
There is also duplication
between 3 - 6 selectors
Outliers were deleted when creating this
figure

CSER FALL 2013 MEETING

25
Grouping adoption

In average, less than 20% of all
selectors of today’s CSS are
grouped selectors.

Open Source

CSER FALL 2013 MEETING

Extracted by Crawler

26
Size and duplication
Spearman test of correlation between size and
duplicated declaration ratio
Rho

p-value

CrawlerExtracted

0.3923908

3.935e-08

Open Source

0.4170468

8.921e-10

CSER FALL 2013 MEETING

27
Grouping and duplication
Open Source

Extracted by Crawler

Spearman test of correlation between
grouping and duplicated declaration ratio
Rho

p-value

Extracted by
Crawler

0.07309612

0.3254

Open Source

-0.1423606

0.04488

CSER FALL 2013 MEETING

28
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
d_mazina@encs.concordia.ca

http://users.encs.concordia.ca/~d_mazina/
CSER FALL 2013 MEETING

30

Contenu connexe

Similaire à An Empirical Study of Duplication in Cascading Style Sheets

Cassandra's Sweet Spot - an introduction to Apache Cassandra
Cassandra's Sweet Spot - an introduction to Apache CassandraCassandra's Sweet Spot - an introduction to Apache Cassandra
Cassandra's Sweet Spot - an introduction to Apache CassandraDave Gardner
 
DevOps and the Future of Enterprise Security
DevOps and the Future of Enterprise SecurityDevOps and the Future of Enterprise Security
DevOps and the Future of Enterprise SecurityFrank Kim
 
Webinar: Dyn + DataStax - helping companies deliver exceptional end-user expe...
Webinar: Dyn + DataStax - helping companies deliver exceptional end-user expe...Webinar: Dyn + DataStax - helping companies deliver exceptional end-user expe...
Webinar: Dyn + DataStax - helping companies deliver exceptional end-user expe...DataStax
 
Beyond MVC: from Model to Domain
Beyond MVC: from Model to DomainBeyond MVC: from Model to Domain
Beyond MVC: from Model to DomainJeremy Cook
 
Consistency vs. Flexibility in Design Systems: A GE Case Study by Ken Skistimas
Consistency vs. Flexibility in Design Systems: A GE Case Study by Ken SkistimasConsistency vs. Flexibility in Design Systems: A GE Case Study by Ken Skistimas
Consistency vs. Flexibility in Design Systems: A GE Case Study by Ken Skistimasuxpin
 
Consistency vs Flexibility in Design Systems : A GE Case Study
Consistency vs Flexibility in Design Systems : A GE Case StudyConsistency vs Flexibility in Design Systems : A GE Case Study
Consistency vs Flexibility in Design Systems : A GE Case StudyKen Skistimas
 
Successfully Implement Responsive Design Behavior with Adobe Experience Manager
Successfully Implement Responsive Design Behavior with Adobe Experience ManagerSuccessfully Implement Responsive Design Behavior with Adobe Experience Manager
Successfully Implement Responsive Design Behavior with Adobe Experience ManagerPerficient, Inc.
 
Databaseconcepts
DatabaseconceptsDatabaseconcepts
Databaseconceptsdilipkkr
 
DDS Advanced Tutorial - OMG June 2013 Berlin Meeting
DDS Advanced Tutorial - OMG June 2013 Berlin MeetingDDS Advanced Tutorial - OMG June 2013 Berlin Meeting
DDS Advanced Tutorial - OMG June 2013 Berlin MeetingJaime Martin Losa
 
Threat Modelling - It's not just for developers
Threat Modelling - It's not just for developersThreat Modelling - It's not just for developers
Threat Modelling - It's not just for developersMITRE ATT&CK
 
Gapand 2017 - Diseñando Arquitecturas Serverless en Azure
Gapand 2017 - Diseñando Arquitecturas Serverless en AzureGapand 2017 - Diseñando Arquitecturas Serverless en Azure
Gapand 2017 - Diseñando Arquitecturas Serverless en AzureAlberto Diaz Martin
 
The Good, The Bad, and The Avro (Graham Stirling, Saxo Bank and David Navalho...
The Good, The Bad, and The Avro (Graham Stirling, Saxo Bank and David Navalho...The Good, The Bad, and The Avro (Graham Stirling, Saxo Bank and David Navalho...
The Good, The Bad, and The Avro (Graham Stirling, Saxo Bank and David Navalho...confluent
 
Delivery Pipelines as a First Class Citizen @deliverAgile2019
Delivery Pipelines as a First Class Citizen @deliverAgile2019Delivery Pipelines as a First Class Citizen @deliverAgile2019
Delivery Pipelines as a First Class Citizen @deliverAgile2019ciberkleid
 
CSS Methodology
CSS MethodologyCSS Methodology
CSS MethodologyZohar Arad
 
Introducing Neo4j 3.0
Introducing Neo4j 3.0Introducing Neo4j 3.0
Introducing Neo4j 3.0Neo4j
 
Webinar: Scaling MongoDB
Webinar: Scaling MongoDBWebinar: Scaling MongoDB
Webinar: Scaling MongoDBMongoDB
 
Scalable constrained spectral clustering
Scalable constrained spectral clusteringScalable constrained spectral clustering
Scalable constrained spectral clusteringNishanth Harapanahalli
 
Groovy In the Cloud
Groovy In the CloudGroovy In the Cloud
Groovy In the CloudJim Driscoll
 
04 CSS #burningkeyboards
04 CSS #burningkeyboards04 CSS #burningkeyboards
04 CSS #burningkeyboardsDenis Ristic
 

Similaire à An Empirical Study of Duplication in Cascading Style Sheets (20)

Cassandra's Sweet Spot - an introduction to Apache Cassandra
Cassandra's Sweet Spot - an introduction to Apache CassandraCassandra's Sweet Spot - an introduction to Apache Cassandra
Cassandra's Sweet Spot - an introduction to Apache Cassandra
 
DevOps and the Future of Enterprise Security
DevOps and the Future of Enterprise SecurityDevOps and the Future of Enterprise Security
DevOps and the Future of Enterprise Security
 
Webinar: Dyn + DataStax - helping companies deliver exceptional end-user expe...
Webinar: Dyn + DataStax - helping companies deliver exceptional end-user expe...Webinar: Dyn + DataStax - helping companies deliver exceptional end-user expe...
Webinar: Dyn + DataStax - helping companies deliver exceptional end-user expe...
 
Knowing it all
Knowing it allKnowing it all
Knowing it all
 
Beyond MVC: from Model to Domain
Beyond MVC: from Model to DomainBeyond MVC: from Model to Domain
Beyond MVC: from Model to Domain
 
Consistency vs. Flexibility in Design Systems: A GE Case Study by Ken Skistimas
Consistency vs. Flexibility in Design Systems: A GE Case Study by Ken SkistimasConsistency vs. Flexibility in Design Systems: A GE Case Study by Ken Skistimas
Consistency vs. Flexibility in Design Systems: A GE Case Study by Ken Skistimas
 
Consistency vs Flexibility in Design Systems : A GE Case Study
Consistency vs Flexibility in Design Systems : A GE Case StudyConsistency vs Flexibility in Design Systems : A GE Case Study
Consistency vs Flexibility in Design Systems : A GE Case Study
 
Successfully Implement Responsive Design Behavior with Adobe Experience Manager
Successfully Implement Responsive Design Behavior with Adobe Experience ManagerSuccessfully Implement Responsive Design Behavior with Adobe Experience Manager
Successfully Implement Responsive Design Behavior with Adobe Experience Manager
 
Databaseconcepts
DatabaseconceptsDatabaseconcepts
Databaseconcepts
 
DDS Advanced Tutorial - OMG June 2013 Berlin Meeting
DDS Advanced Tutorial - OMG June 2013 Berlin MeetingDDS Advanced Tutorial - OMG June 2013 Berlin Meeting
DDS Advanced Tutorial - OMG June 2013 Berlin Meeting
 
Threat Modelling - It's not just for developers
Threat Modelling - It's not just for developersThreat Modelling - It's not just for developers
Threat Modelling - It's not just for developers
 
Gapand 2017 - Diseñando Arquitecturas Serverless en Azure
Gapand 2017 - Diseñando Arquitecturas Serverless en AzureGapand 2017 - Diseñando Arquitecturas Serverless en Azure
Gapand 2017 - Diseñando Arquitecturas Serverless en Azure
 
The Good, The Bad, and The Avro (Graham Stirling, Saxo Bank and David Navalho...
The Good, The Bad, and The Avro (Graham Stirling, Saxo Bank and David Navalho...The Good, The Bad, and The Avro (Graham Stirling, Saxo Bank and David Navalho...
The Good, The Bad, and The Avro (Graham Stirling, Saxo Bank and David Navalho...
 
Delivery Pipelines as a First Class Citizen @deliverAgile2019
Delivery Pipelines as a First Class Citizen @deliverAgile2019Delivery Pipelines as a First Class Citizen @deliverAgile2019
Delivery Pipelines as a First Class Citizen @deliverAgile2019
 
CSS Methodology
CSS MethodologyCSS Methodology
CSS Methodology
 
Introducing Neo4j 3.0
Introducing Neo4j 3.0Introducing Neo4j 3.0
Introducing Neo4j 3.0
 
Webinar: Scaling MongoDB
Webinar: Scaling MongoDBWebinar: Scaling MongoDB
Webinar: Scaling MongoDB
 
Scalable constrained spectral clustering
Scalable constrained spectral clusteringScalable constrained spectral clustering
Scalable constrained spectral clustering
 
Groovy In the Cloud
Groovy In the CloudGroovy In the Cloud
Groovy In the Cloud
 
04 CSS #burningkeyboards
04 CSS #burningkeyboards04 CSS #burningkeyboards
04 CSS #burningkeyboards
 

Plus de Nikolaos Tsantalis

Refactoring Mining - The key to unlock software evolution
Refactoring Mining - The key to unlock software evolutionRefactoring Mining - The key to unlock software evolution
Refactoring Mining - The key to unlock software evolutionNikolaos Tsantalis
 
CASCON 2023 Most Influential Paper Award Talk
CASCON 2023 Most Influential Paper Award TalkCASCON 2023 Most Influential Paper Award Talk
CASCON 2023 Most Influential Paper Award TalkNikolaos Tsantalis
 
SANER 2019 Most Influential Paper Talk
SANER 2019 Most Influential Paper TalkSANER 2019 Most Influential Paper Talk
SANER 2019 Most Influential Paper TalkNikolaos Tsantalis
 
Accurate and Efficient Refactoring Detection in Commit History
Accurate and Efficient Refactoring Detection in Commit HistoryAccurate and Efficient Refactoring Detection in Commit History
Accurate and Efficient Refactoring Detection in Commit HistoryNikolaos Tsantalis
 
Clone Refactoring with Lambda Expressions
Clone Refactoring with Lambda ExpressionsClone Refactoring with Lambda Expressions
Clone Refactoring with Lambda ExpressionsNikolaos Tsantalis
 
Why We Refactor? Confessions of GitHub Contributors
Why We Refactor? Confessions of GitHub ContributorsWhy We Refactor? Confessions of GitHub Contributors
Why We Refactor? Confessions of GitHub ContributorsNikolaos Tsantalis
 
Migrating cascading style sheets to preprocessors
Migrating cascading style sheets to preprocessorsMigrating cascading style sheets to preprocessors
Migrating cascading style sheets to preprocessorsNikolaos Tsantalis
 
An empirical study on the use of CSS preprocessors
An empirical study on the use of CSS preprocessorsAn empirical study on the use of CSS preprocessors
An empirical study on the use of CSS preprocessorsNikolaos Tsantalis
 
An Empirical Study on the Use of CSS Preprocessors
An Empirical Study on the Use of CSS PreprocessorsAn Empirical Study on the Use of CSS Preprocessors
An Empirical Study on the Use of CSS PreprocessorsNikolaos Tsantalis
 
Code Smell Research: History and Future Directions
Code Smell Research: History and Future DirectionsCode Smell Research: History and Future Directions
Code Smell Research: History and Future DirectionsNikolaos Tsantalis
 
Preventive Software Maintenance: The Past, the Present, the Future
Preventive Software Maintenance: The Past, the Present, the FuturePreventive Software Maintenance: The Past, the Present, the Future
Preventive Software Maintenance: The Past, the Present, the FutureNikolaos Tsantalis
 
Ranking Refactoring Suggestions based on Historical Volatility
Ranking Refactoring Suggestions based on Historical VolatilityRanking Refactoring Suggestions based on Historical Volatility
Ranking Refactoring Suggestions based on Historical VolatilityNikolaos Tsantalis
 
Feature Detection in Ajax-enabled Web Applications
Feature Detection in Ajax-enabled Web ApplicationsFeature Detection in Ajax-enabled Web Applications
Feature Detection in Ajax-enabled Web ApplicationsNikolaos Tsantalis
 
A Multidimensional Empirical Study on Refactoring Activity
A Multidimensional Empirical Study on Refactoring ActivityA Multidimensional Empirical Study on Refactoring Activity
A Multidimensional Empirical Study on Refactoring ActivityNikolaos Tsantalis
 
Unification and Refactoring of Clones
Unification and Refactoring of ClonesUnification and Refactoring of Clones
Unification and Refactoring of ClonesNikolaos Tsantalis
 

Plus de Nikolaos Tsantalis (16)

Refactoring Mining - The key to unlock software evolution
Refactoring Mining - The key to unlock software evolutionRefactoring Mining - The key to unlock software evolution
Refactoring Mining - The key to unlock software evolution
 
CASCON 2023 Most Influential Paper Award Talk
CASCON 2023 Most Influential Paper Award TalkCASCON 2023 Most Influential Paper Award Talk
CASCON 2023 Most Influential Paper Award Talk
 
SANER 2019 Most Influential Paper Talk
SANER 2019 Most Influential Paper TalkSANER 2019 Most Influential Paper Talk
SANER 2019 Most Influential Paper Talk
 
Accurate and Efficient Refactoring Detection in Commit History
Accurate and Efficient Refactoring Detection in Commit HistoryAccurate and Efficient Refactoring Detection in Commit History
Accurate and Efficient Refactoring Detection in Commit History
 
Clone Refactoring with Lambda Expressions
Clone Refactoring with Lambda ExpressionsClone Refactoring with Lambda Expressions
Clone Refactoring with Lambda Expressions
 
Why We Refactor? Confessions of GitHub Contributors
Why We Refactor? Confessions of GitHub ContributorsWhy We Refactor? Confessions of GitHub Contributors
Why We Refactor? Confessions of GitHub Contributors
 
Migrating cascading style sheets to preprocessors
Migrating cascading style sheets to preprocessorsMigrating cascading style sheets to preprocessors
Migrating cascading style sheets to preprocessors
 
JDeodorant: Clone Refactoring
JDeodorant: Clone RefactoringJDeodorant: Clone Refactoring
JDeodorant: Clone Refactoring
 
An empirical study on the use of CSS preprocessors
An empirical study on the use of CSS preprocessorsAn empirical study on the use of CSS preprocessors
An empirical study on the use of CSS preprocessors
 
An Empirical Study on the Use of CSS Preprocessors
An Empirical Study on the Use of CSS PreprocessorsAn Empirical Study on the Use of CSS Preprocessors
An Empirical Study on the Use of CSS Preprocessors
 
Code Smell Research: History and Future Directions
Code Smell Research: History and Future DirectionsCode Smell Research: History and Future Directions
Code Smell Research: History and Future Directions
 
Preventive Software Maintenance: The Past, the Present, the Future
Preventive Software Maintenance: The Past, the Present, the FuturePreventive Software Maintenance: The Past, the Present, the Future
Preventive Software Maintenance: The Past, the Present, the Future
 
Ranking Refactoring Suggestions based on Historical Volatility
Ranking Refactoring Suggestions based on Historical VolatilityRanking Refactoring Suggestions based on Historical Volatility
Ranking Refactoring Suggestions based on Historical Volatility
 
Feature Detection in Ajax-enabled Web Applications
Feature Detection in Ajax-enabled Web ApplicationsFeature Detection in Ajax-enabled Web Applications
Feature Detection in Ajax-enabled Web Applications
 
A Multidimensional Empirical Study on Refactoring Activity
A Multidimensional Empirical Study on Refactoring ActivityA Multidimensional Empirical Study on Refactoring Activity
A Multidimensional Empirical Study on Refactoring Activity
 
Unification and Refactoring of Clones
Unification and Refactoring of ClonesUnification and Refactoring of Clones
Unification and Refactoring of Clones
 

Dernier

Hire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls AgencyHire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls AgencySheetal Arora
 
DIFFERENCE IN BACK CROSS AND TEST CROSS
DIFFERENCE IN  BACK CROSS AND TEST CROSSDIFFERENCE IN  BACK CROSS AND TEST CROSS
DIFFERENCE IN BACK CROSS AND TEST CROSSLeenakshiTyagi
 
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...ssifa0344
 
Pests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdfPests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdfPirithiRaju
 
Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )aarthirajkumar25
 
Chemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdfChemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdfSumit Kumar yadav
 
Botany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdfBotany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdfSumit Kumar yadav
 
VIRUSES structure and classification ppt by Dr.Prince C P
VIRUSES structure and classification ppt by Dr.Prince C PVIRUSES structure and classification ppt by Dr.Prince C P
VIRUSES structure and classification ppt by Dr.Prince C PPRINCE C P
 
Spermiogenesis or Spermateleosis or metamorphosis of spermatid
Spermiogenesis or Spermateleosis or metamorphosis of spermatidSpermiogenesis or Spermateleosis or metamorphosis of spermatid
Spermiogenesis or Spermateleosis or metamorphosis of spermatidSarthak Sekhar Mondal
 
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPirithiRaju
 
fundamental of entomology all in one topics of entomology
fundamental of entomology all in one topics of entomologyfundamental of entomology all in one topics of entomology
fundamental of entomology all in one topics of entomologyDrAnita Sharma
 
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...Lokesh Kothari
 
Biopesticide (2).pptx .This slides helps to know the different types of biop...
Biopesticide (2).pptx  .This slides helps to know the different types of biop...Biopesticide (2).pptx  .This slides helps to know the different types of biop...
Biopesticide (2).pptx .This slides helps to know the different types of biop...RohitNehra6
 
GBSN - Biochemistry (Unit 1)
GBSN - Biochemistry (Unit 1)GBSN - Biochemistry (Unit 1)
GBSN - Biochemistry (Unit 1)Areesha Ahmad
 
Unlocking the Potential: Deep dive into ocean of Ceramic Magnets.pptx
Unlocking  the Potential: Deep dive into ocean of Ceramic Magnets.pptxUnlocking  the Potential: Deep dive into ocean of Ceramic Magnets.pptx
Unlocking the Potential: Deep dive into ocean of Ceramic Magnets.pptxanandsmhk
 
Biological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfBiological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfmuntazimhurra
 
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...Sérgio Sacani
 
Nanoparticles synthesis and characterization​ ​
Nanoparticles synthesis and characterization​  ​Nanoparticles synthesis and characterization​  ​
Nanoparticles synthesis and characterization​ ​kaibalyasahoo82800
 
Disentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOSTDisentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOSTSérgio Sacani
 
Chromatin Structure | EUCHROMATIN | HETEROCHROMATIN
Chromatin Structure | EUCHROMATIN | HETEROCHROMATINChromatin Structure | EUCHROMATIN | HETEROCHROMATIN
Chromatin Structure | EUCHROMATIN | HETEROCHROMATINsankalpkumarsahoo174
 

Dernier (20)

Hire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls AgencyHire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
 
DIFFERENCE IN BACK CROSS AND TEST CROSS
DIFFERENCE IN  BACK CROSS AND TEST CROSSDIFFERENCE IN  BACK CROSS AND TEST CROSS
DIFFERENCE IN BACK CROSS AND TEST CROSS
 
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
 
Pests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdfPests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdf
 
Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )
 
Chemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdfChemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdf
 
Botany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdfBotany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdf
 
VIRUSES structure and classification ppt by Dr.Prince C P
VIRUSES structure and classification ppt by Dr.Prince C PVIRUSES structure and classification ppt by Dr.Prince C P
VIRUSES structure and classification ppt by Dr.Prince C P
 
Spermiogenesis or Spermateleosis or metamorphosis of spermatid
Spermiogenesis or Spermateleosis or metamorphosis of spermatidSpermiogenesis or Spermateleosis or metamorphosis of spermatid
Spermiogenesis or Spermateleosis or metamorphosis of spermatid
 
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
 
fundamental of entomology all in one topics of entomology
fundamental of entomology all in one topics of entomologyfundamental of entomology all in one topics of entomology
fundamental of entomology all in one topics of entomology
 
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
 
Biopesticide (2).pptx .This slides helps to know the different types of biop...
Biopesticide (2).pptx  .This slides helps to know the different types of biop...Biopesticide (2).pptx  .This slides helps to know the different types of biop...
Biopesticide (2).pptx .This slides helps to know the different types of biop...
 
GBSN - Biochemistry (Unit 1)
GBSN - Biochemistry (Unit 1)GBSN - Biochemistry (Unit 1)
GBSN - Biochemistry (Unit 1)
 
Unlocking the Potential: Deep dive into ocean of Ceramic Magnets.pptx
Unlocking  the Potential: Deep dive into ocean of Ceramic Magnets.pptxUnlocking  the Potential: Deep dive into ocean of Ceramic Magnets.pptx
Unlocking the Potential: Deep dive into ocean of Ceramic Magnets.pptx
 
Biological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfBiological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdf
 
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
 
Nanoparticles synthesis and characterization​ ​
Nanoparticles synthesis and characterization​  ​Nanoparticles synthesis and characterization​  ​
Nanoparticles synthesis and characterization​ ​
 
Disentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOSTDisentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOST
 
Chromatin Structure | EUCHROMATIN | HETEROCHROMATIN
Chromatin Structure | EUCHROMATIN | HETEROCHROMATINChromatin Structure | EUCHROMATIN | HETEROCHROMATIN
Chromatin Structure | EUCHROMATIN | HETEROCHROMATIN
 

An Empirical Study of Duplication in Cascading Style Sheets

  • 1. An Empirical Study of Duplication in Cascading Style Sheets D avo o d M a z i n a n i a n , N i ko l a o s Ts a n t a l i s C o n c o rd i a U n ive r s i t y, M o n t re a l CSER FALL 2013 MEETING 1
  • 2. 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
  • 3. 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
  • 4. Exploiting CSS Pure CSS + HTML CSER FALL 2013 MEETING 4
  • 5. 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] 100% 90% 80% 70% 60% 50% 40% 30% 20% 10% 0% Mozilla survey results: What programming language do you use? CSER FALL 2013 MEETING 5
  • 6. Syntax No variables or functions… ◦ So we may have duplication in value, declaration and selector level CSER FALL 2013 MEETING 6
  • 7. 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 @nice-blue: #5B83AD; @light-blue: (@nice-blue + #111); #header { color: @light-blue; } #header { color: #6c94be; } CSS LESS ◦ But the generated CSS files still have significant duplication CSER FALL 2013 MEETING 7
  • 8. 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
  • 9. 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
  • 10. 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
  • 11. Types of duplications We defined Three types of declaration duplication CSER FALL 2013 MEETING 11
  • 12. Gmail’s main CSS file had more than 18000 LOC, when formatted TYPE I Declarations with the lexically same property and values. There are 23 repeated declarations for three different selectors! .z-b-ua { /* 17972 */ .z-b-ga { /* 16871 */ … … color: #fff; color: #fff; cursor: default; cursor: default; font-size: 11px; font-size: 11px; font-weight: bold; font-weight: bold; text-align: center; text-align: center; white-space: nowrap; white-space: nowrap; border: 1px solid border: 1px solid transparent; transparent; border-radius: 2px; border-radius: 2px; … … transition-duration: .218s; transition-duration: .218s; … … CSER FALL 2013 MEETING 12
  • 13. .iF9mle { /* 8742 */ … background: white; … } TYPE II Declarations with the: • Same properties with equivalent values • Or same properties with missing default values that are implied. .c-S-aa { /* 14120 */ … background: #fff; … } .c-i { /* 18213 */ … -webkit-transition: opacity .218s; transition: opacity .218s; … } .kz { /* 10691 */ … -webkit-transition: opacity .218s ease; transition: opacity .218s ease } CSER FALL 2013 MEETING 13
  • 14. TYPE III Set of individual declarations, and the equivalent shorthand declaration in another selector .qfacj { /* 8723 */ … border-style: solid; border-width: 1px; border-color: #ccc; … } Individual declarations .c-i { /* 18213 */ … border: 1px solid #ccc; … } Shorthand declaration CSER FALL 2013 MEETING 14
  • 15. 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
  • 16. 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
  • 17. 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 .Selector_A { color: #fff; cursor: default; font-size: 11px; font-weight: bold; } .Selector_A, .Selector_B { color: #fff; cursor: default; font-size: 11px; font-weight: bold; } .Selector_B { color: #fff; cursor: default; font-size: 11px; font-weight: bold; } CSER FALL 2013 MEETING 17
  • 18. Data mining metaphor Lets consider: ◦ CSS file is a transaction database, ◦ Every selector is a transaction, ◦ Every declaration is an item .Selector_A { color: #fff; cursor: default; font-size: 11px; } .Selector_B { color: #fff; font-size: 11px; font-weight: bold; } Transaction ID Items Selector_A color: #fff; cursor: default; font-size: 11px; Selector_B color: #fff; font-size: 11px; font-weight: bold; CSER FALL 2013 MEETING 18
  • 19. Frequent Itemset generation 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 CSER FALL 2013 MEETING 19
  • 20. Frequent itemset generation .Selector_A { color: #fff; cursor: default; font-size: 11px; } Transaction ID Items .Selector_A .Selector_B { color: #fff; font-size: 11px; font-weight: bold; } color: #fff; cursor: default; font-size: 11px; .Selector_B color: #fff; font-size: 11px; font-weight: bold; Frequent Itemset { color: #fff, font-size: 11px; } CSER FALL 2013 MEETING Support .Selector_A, .Selector_B 20
  • 21. 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
  • 22. 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
  • 23. Duplication at declaration level About 60% of declarations are duplicated CSER FALL 2013 MEETING 23
  • 24. Largest duplications The median of the largest number of common declarations is 5 and 7 respectively CSER FALL 2013 MEETING 24
  • 25. Largest duplications • • • The majority of duplication is between two selectors. There is also duplication between 3 - 6 selectors Outliers were deleted when creating this figure CSER FALL 2013 MEETING 25
  • 26. Grouping adoption In average, less than 20% of all selectors of today’s CSS are grouped selectors. Open Source CSER FALL 2013 MEETING Extracted by Crawler 26
  • 27. Size and duplication Spearman test of correlation between size and duplicated declaration ratio Rho p-value CrawlerExtracted 0.3923908 3.935e-08 Open Source 0.4170468 8.921e-10 CSER FALL 2013 MEETING 27
  • 28. Grouping and duplication Open Source Extracted by Crawler Spearman test of correlation between grouping and duplicated declaration ratio Rho p-value Extracted by Crawler 0.07309612 0.3254 Open Source -0.1423606 0.04488 CSER FALL 2013 MEETING 28
  • 29. 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

Notes de l'éditeur

  1. Eclat uses set intersection…
  2. Extracted by crawler
  3. Add the conclusions