SlideShare ist ein Scribd-Unternehmen logo
1 von 39
Myths of CSS
Preprocessors
Ramon Lapenta - @ramono - #sass
About me
• Frontend developer @ Cyber-Duck Ltd
• Making websites for over 10 years
• Love what I do for a living
• Love to talk about it
What are CSS Preprocessors?
• A way of adding functionality to CSS in the
form of mixins, extends, functions.
What are CSS Preprocessors?
• A way of reducing development time by
using variables and nesting rules.
Usage stats: Europe
Usage stats: America
Usage stats: America
Why use preprocessors?
1. CSS is repetitive
2. CSS doesn’t have variables
3. Inflexible, limited reusability
4. Complex websites are hard to maintain
The Myths
1.Adds complexity to the development process
2.You lose control over the final code
3.Adds overhead to the website
4.Adds extra dependencies to your workflow
5.Too hard to debug
The Myths
God, SCSS looks like
JavaScript and PHP
mated in a drunken state.
Christian Heilmann
Bull!
The Famous Bull Of Wall Street - http://goo.gl/kKsghb
Lets debunk
the myths!
Myth: Complexity
• Nesting is a natural way of coding
• Named variables are easier to manage than
individual values like colours (E.g.
#0E2740)
• You don’t have to use all the functionality
Myth: Lose control
• If your CSS code is currently horrible, your
Sass will undoubtedly be horrible
• Sass doesn’t write code by itself
• Use expanded output option during
development
Myth: Overhead
• Compiled file is just plain CSS
• Automatically minify/compress
• Easy to add (or remove) vendor evil
prefixes
• Seamless file concatenation
Myth: Dependencies
• Your current set up has many
dependencies
• If you don’t use a pre-processor, you need
a post-processor
• Many tools are available for free, for every
platform
Myth: Hard to debug
• Organised code shouldn’t be hard to debug
• There are ways
• It’s getting better
• The cost is low compared to the benefit
Resources & Tools
Documentation
• All three major pre-processors have
excellent documentation online
• Tutorials available
• Videos everywhere
Graphic Tools
• Codekit
(http://incident57.com/codekit/)
• Prepros
(http://alphapixels.com/prepros/)
• Compass
(http://compass.kkbox.com)
• Hammer
(http://hammerformac.com)
• Koala (http://koala-app.com)
• Mixture (http://mixture.io)
LiveReload (http://livereload.com)
Scout
(http://mhs.github.io/scout-app/)
Crunch (http://crunchapp.net)
SimpleLess
(http://wearekiss.com/simpless)
WinLess (http://winless.org)
LessApp
(http://incident57.com/less/)
Other tools
• Brunch.io
• Grunt!
• Buildr
• Gulp
• Command line
(it’s not hard)
$ sass --watch file.scss:file.css
$ sass --watch scss:css
Watch a file
Watch a folder
Techniques &
Tips
Debug: —debug-info
• Debug info flag tells you with a comment where
the rule is located in the source file.
• Available only up to Sass 3.2
$ sass --watch —style expanded —debug-info scss:css
Watch a folder
/* _head.scss line: 24 */
.head {
background-color: darkslateblue;
}
Output
Debug: Chrome inspector
• Chrome 30+ includes
Sourcemap (Sass 3.3
and Less 1.5+) support
by default
• Stylus considering it
Debug: Chrome inspector
• Sourcemaps creates a map of your CSS
• Available only on Sass 3.3+
$ lessc common.less > common.css
Watch the folder
common.css
common.map
Output
Debug: File organisation
• Divide and conquer
• Master the
@import rules and
file concatenation
• It’s easier to find a
rule in a small file
public/
assets/
css/
styles.css
img/
js/
scss/
_carousel.scss
_contact.scss
_grid.scss
_home.scss
_typo.scss
styles.scss
Tip: File organisation
• Import within media queries so don’t repeat
media queries
@media (max-width: 599px) {
@import “small/base.scss”;
}
• Make one file by component / section with
all its media queries
Tip: Mixins
• Mixins are
parametrisable
snippets of code
@mixin box($type: border-box) {
box-sizing: $type;
-ms-box-sizing: $type;
-moz-box-sizing: $type;
-webkit-box-sizing: $type;
}
.box {
padding: 20px;
width: 100%;
@include box(border-box);
}
Tip: Mixins
• Easy way to add
prefixes .box {
padding: 20px;
width: 100%;
box-sizing: border-box;
-ms-box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
}
Tip: Extends
• Extends allows you
to alter rules
without repeating
code
• Use % to create a
rule that outputs
code only when
extended.
.go {
color: $white;
padding: 5px 10px;
border-radius: 5px;
text-decoration: none;
font-size: 1em;
text-transform: uppercase;
background-color: $green;
}
.cancel {
@extend .go;
background-color: $red;
}
Tip: Extends
• Clever separation
.go, .cancel {
color: white;
padding: 5px 10px;
border-radius: 5px;
text-decoration: none;
font-size: 1em;
text-transform: uppercase;
background-color: green;
}
.cancel {
background-color: red;
}
Tip: Nesting
• Nesting feels right
• It’s easy and you
write less
.box {
float: right;
footer {
padding: 20px;
.btn {
color: $white;
}
}
}
Tip: Nesting
• Easy to get carried away
• Can bring over-specificity issues
/ Compiles to
.box {
float: right;
}
.box footer {
padding: 20px;
}
.box footer .btn {
color: white;
}
Tip: Github resources
• Tons of resources:
Mixins, frameworks, libraries, tutorials,
Tip pitch: hoisin.scss
• Light & extensible
• Responsive
• Doesn’t make any design assumptions
• Mobile first, Content first, Performance first
• http://cyber-duck.github.io/hoisin.scss/
Which one is the best?
• Sass!
• All have about the same functionality
• Ensure it fits with your workflow
• Compatibility with existing code
• What feels better to you?
The Myths
1. Adds complexity to the development process
2. You lose control over the final code
3. Adds overhead to the website
4. Adds extra dependencies to your workflow
5. Too hard to debug
Final Considerations
• If you are a CSS beginner
• You need to know how CSS works before
using a pre-processor
• Source Control: ignore compiled / compile on
deployment
Thanks!
Ramon Lapenta - @ramono - sxsw.com/rate

Weitere ähnliche Inhalte

Kürzlich hochgeladen

The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 

Kürzlich hochgeladen (20)

The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 

Empfohlen

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Empfohlen (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Myths about CSS Pre processors

  • 1. Myths of CSS Preprocessors Ramon Lapenta - @ramono - #sass
  • 2. About me • Frontend developer @ Cyber-Duck Ltd • Making websites for over 10 years • Love what I do for a living • Love to talk about it
  • 3. What are CSS Preprocessors? • A way of adding functionality to CSS in the form of mixins, extends, functions.
  • 4. What are CSS Preprocessors? • A way of reducing development time by using variables and nesting rules.
  • 8. Why use preprocessors? 1. CSS is repetitive 2. CSS doesn’t have variables 3. Inflexible, limited reusability 4. Complex websites are hard to maintain
  • 9. The Myths 1.Adds complexity to the development process 2.You lose control over the final code 3.Adds overhead to the website 4.Adds extra dependencies to your workflow 5.Too hard to debug
  • 10. The Myths God, SCSS looks like JavaScript and PHP mated in a drunken state. Christian Heilmann
  • 11. Bull! The Famous Bull Of Wall Street - http://goo.gl/kKsghb
  • 13. Myth: Complexity • Nesting is a natural way of coding • Named variables are easier to manage than individual values like colours (E.g. #0E2740) • You don’t have to use all the functionality
  • 14. Myth: Lose control • If your CSS code is currently horrible, your Sass will undoubtedly be horrible • Sass doesn’t write code by itself • Use expanded output option during development
  • 15. Myth: Overhead • Compiled file is just plain CSS • Automatically minify/compress • Easy to add (or remove) vendor evil prefixes • Seamless file concatenation
  • 16. Myth: Dependencies • Your current set up has many dependencies • If you don’t use a pre-processor, you need a post-processor • Many tools are available for free, for every platform
  • 17. Myth: Hard to debug • Organised code shouldn’t be hard to debug • There are ways • It’s getting better • The cost is low compared to the benefit
  • 19. Documentation • All three major pre-processors have excellent documentation online • Tutorials available • Videos everywhere
  • 20. Graphic Tools • Codekit (http://incident57.com/codekit/) • Prepros (http://alphapixels.com/prepros/) • Compass (http://compass.kkbox.com) • Hammer (http://hammerformac.com) • Koala (http://koala-app.com) • Mixture (http://mixture.io) LiveReload (http://livereload.com) Scout (http://mhs.github.io/scout-app/) Crunch (http://crunchapp.net) SimpleLess (http://wearekiss.com/simpless) WinLess (http://winless.org) LessApp (http://incident57.com/less/)
  • 21. Other tools • Brunch.io • Grunt! • Buildr • Gulp • Command line (it’s not hard) $ sass --watch file.scss:file.css $ sass --watch scss:css Watch a file Watch a folder
  • 23. Debug: —debug-info • Debug info flag tells you with a comment where the rule is located in the source file. • Available only up to Sass 3.2 $ sass --watch —style expanded —debug-info scss:css Watch a folder /* _head.scss line: 24 */ .head { background-color: darkslateblue; } Output
  • 24. Debug: Chrome inspector • Chrome 30+ includes Sourcemap (Sass 3.3 and Less 1.5+) support by default • Stylus considering it
  • 25. Debug: Chrome inspector • Sourcemaps creates a map of your CSS • Available only on Sass 3.3+ $ lessc common.less > common.css Watch the folder common.css common.map Output
  • 26. Debug: File organisation • Divide and conquer • Master the @import rules and file concatenation • It’s easier to find a rule in a small file public/ assets/ css/ styles.css img/ js/ scss/ _carousel.scss _contact.scss _grid.scss _home.scss _typo.scss styles.scss
  • 27. Tip: File organisation • Import within media queries so don’t repeat media queries @media (max-width: 599px) { @import “small/base.scss”; } • Make one file by component / section with all its media queries
  • 28. Tip: Mixins • Mixins are parametrisable snippets of code @mixin box($type: border-box) { box-sizing: $type; -ms-box-sizing: $type; -moz-box-sizing: $type; -webkit-box-sizing: $type; } .box { padding: 20px; width: 100%; @include box(border-box); }
  • 29. Tip: Mixins • Easy way to add prefixes .box { padding: 20px; width: 100%; box-sizing: border-box; -ms-box-sizing: border-box; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; }
  • 30. Tip: Extends • Extends allows you to alter rules without repeating code • Use % to create a rule that outputs code only when extended. .go { color: $white; padding: 5px 10px; border-radius: 5px; text-decoration: none; font-size: 1em; text-transform: uppercase; background-color: $green; } .cancel { @extend .go; background-color: $red; }
  • 31. Tip: Extends • Clever separation .go, .cancel { color: white; padding: 5px 10px; border-radius: 5px; text-decoration: none; font-size: 1em; text-transform: uppercase; background-color: green; } .cancel { background-color: red; }
  • 32. Tip: Nesting • Nesting feels right • It’s easy and you write less .box { float: right; footer { padding: 20px; .btn { color: $white; } } }
  • 33. Tip: Nesting • Easy to get carried away • Can bring over-specificity issues / Compiles to .box { float: right; } .box footer { padding: 20px; } .box footer .btn { color: white; }
  • 34. Tip: Github resources • Tons of resources: Mixins, frameworks, libraries, tutorials,
  • 35. Tip pitch: hoisin.scss • Light & extensible • Responsive • Doesn’t make any design assumptions • Mobile first, Content first, Performance first • http://cyber-duck.github.io/hoisin.scss/
  • 36. Which one is the best? • Sass! • All have about the same functionality • Ensure it fits with your workflow • Compatibility with existing code • What feels better to you?
  • 37. The Myths 1. Adds complexity to the development process 2. You lose control over the final code 3. Adds overhead to the website 4. Adds extra dependencies to your workflow 5. Too hard to debug
  • 38. Final Considerations • If you are a CSS beginner • You need to know how CSS works before using a pre-processor • Source Control: ignore compiled / compile on deployment
  • 39. Thanks! Ramon Lapenta - @ramono - sxsw.com/rate