SlideShare a Scribd company logo
1 of 17
Download to read offline
Client Side Performance
Compromises Worth
Making
Sydney Web Apps Group: 19.9.13
@cathyblabla
What!!?
Good client-side performance really is simple -
smaller files, fewer HTTP requests, less DOM
manipulation. Use YSlow and understand the
rules it is based on.
OK, so there are lots of tricky details that we
could go into, like CSS selector performance,
but is your site huge enough for things like that
to make a difference? Probably not. So….
Where to draw the line
Where do you draw the line between good
performance and maintainability? Class names
like ‘a1’ to make your CSS files smaller? No
way! But there some situations where ‘The
Rules’ can and should be bent...
Multiple sprite images
Sprites allows us to download all our image
assets in one request. If you use Compass, it’s
sprite functionality makes this super simple.
But all those disparate colour palettes add up,
resulting in either a big 32bit PNG or degraded
colour reproduction. The solution? Split up your
sprites into similar colour groups and stick to a
set pallette. It’s a few more HTTP requests but
worth it.
Like this...
$green-sprites: sprite-map("sprites/green/*.png");
$grey-sprites: sprite-map("sprites/grey/*.png");
%mail-icon {
background: sprite($grey-sprites, mail) no-repeat;
&:hover {
background: sprite($green-sprites, mail) no-repeat;
}
}
Scaling images in HTML
Ideally, we would only download images at the
exact size they will be displayed, but your
responsive site will probably call for fluid
images to cater for different devices - what to
do!?
If you can, serve different sized images based
on device categories then allow CSS scaling to
take over.
Choose image sizes that match your target
devices closely and that are close to the upper
end of your breakpoint to minimise image
degradation.
Include the served image’s width and height in
your html to reduce the visible effect of reflows
once your image is loaded.
Load (most) scripts at the bottom of
the page
Inserting scripts at the end of your page stops
script downloads from blocking the rest of your
content. But long pages can result in a
noticeable lag for script effects - while your
overall page load time may be improved the
users’ perception of load time could be
affected.
...so should I load my scripts in
<head> after all?
One approach is to load your ‘must have’
scripts in the head, then load the rest at the
bottom of the page. While this introduces some
maintenance overhead, your page loads as fast
as possible while also giving your users a
seamless experience.
Script loaders FTW!
RequireJS is a script loader that present a
unique solution to this problem. Out of the box,
RequireJS loads modules asynchronously as
they are called for. There is also an
optimisation tool that provides an automated
build. All the files required for your project are
minified and concatenated, this file is then
loaded asynchronously. Your scripts are
optimised, available earlier and are non-
blocking. Yay!
What about lazy loading?
It is possible to squeeze even more
performance out of your Require scripts by
splitting them up and lazy loading those that
are less often needed. Read about it here.
YUI includes a script loader that is based on
RequireJS but also utilises a server side combo
handler that serves back separate files in one
request. The combo loader is open source and
you can get it here.
Some OO in your SASS
Love the modular approach of OOCSS but don’
t like your HTML getting cluttered up with non
semantic class names? With SASS you have
the tools to write modular, concise code that
can be constructed in any way you wish.
Create a structural hierarchy within your SASS
code and push design complexity back to the
style layer to keep your HTML simple and
readable.
Use placeholders to create re-usable
structures...
%btn {
@include rnd( 3px );
border: 1px solid grey;
cursor: pointer;
line-height: 2.3;
padding: 0 17px;
text-decoration: none;
}
.my-button {
@extend %btn;
color: green;
}
Build up top level rules from
combinations of re-usables
.news-module {
@extend %media-block;
@extend %media-module;
.top-stories {
@extend %stories-list;
}
.more-link {
@extend %btn;
}
}
Mixins give you more flexibility...
@mixin button ($colour: green) {
@include background-image(
linear-gradient(white, $colour)
);
border: 1px solid darken($colour, 40%);
color: 1px solid lighten($colour, 20%);
}
.delete-button {
@include button(red);
}
.active-button {
@include button(blue);
}
But be careful of the final output...
Placeholders generate a single rule with all
selectors combined. If you have too many, IE
goes kaboom!
.btn1, .btn2, .btn { //styles extended from %btn }
Mixin styles are repeated wherever they are
used, so use them minimally, ideally for styles
that are unique (ie, based on a parameter).
.delete-button {
background-image(
linear-gradient(white, red)
);
border: 1px solid #660000;
color: 1px solid #FFBFBF;
}
.active-button {
background-image(
linear-gradient(white, blue)
);
border: 1px solid #000066;
color: 1px solid #99CCFF;
}

More Related Content

What's hot

Introduction to Web Development
Introduction to Web DevelopmentIntroduction to Web Development
Introduction to Web DevelopmentParvez Mahbub
 
Asp.net introduction
Asp.net introductionAsp.net introduction
Asp.net introductionKshitij Wagle
 
Ajax
AjaxAjax
AjaxHome
 
Html Templating - DOT JS
Html Templating - DOT JSHtml Templating - DOT JS
Html Templating - DOT JSNagaraju Sangam
 
Web Development basics with WordPress
Web Development basics with WordPressWeb Development basics with WordPress
Web Development basics with WordPressRashna Maharjan
 
The Importance Things of Full Stack Development
The Importance Things of Full Stack DevelopmentThe Importance Things of Full Stack Development
The Importance Things of Full Stack DevelopmentMike Taylor
 
Scaling Wordpress
Scaling WordpressScaling Wordpress
Scaling Wordpressngonpham
 
Introduction to Basic Concepts in Web
Introduction to Basic Concepts in WebIntroduction to Basic Concepts in Web
Introduction to Basic Concepts in WebJussi Pohjolainen
 
Thin Server Architecture SPA, 5 years old presentation
Thin Server Architecture SPA, 5 years old presentationThin Server Architecture SPA, 5 years old presentation
Thin Server Architecture SPA, 5 years old presentationDavid Amend
 
Introduction To Website Development
Introduction To Website DevelopmentIntroduction To Website Development
Introduction To Website Developmentzaidfarooqui974
 
Client side vs server side
Client side vs server sideClient side vs server side
Client side vs server sideabgjim96
 
Thin Server Architecture
Thin Server ArchitectureThin Server Architecture
Thin Server ArchitectureMitch Pirtle
 
Web development classes in pune
Web development classes in puneWeb development classes in pune
Web development classes in puneNidhi Samdani
 
Web deveplopment courses in pune
Web deveplopment courses  in puneWeb deveplopment courses  in pune
Web deveplopment courses in puneNidhi Samdani
 

What's hot (18)

Introduction to Web Development
Introduction to Web DevelopmentIntroduction to Web Development
Introduction to Web Development
 
Asp.net introduction
Asp.net introductionAsp.net introduction
Asp.net introduction
 
Ajax
AjaxAjax
Ajax
 
Ajax
AjaxAjax
Ajax
 
Html Templating - DOT JS
Html Templating - DOT JSHtml Templating - DOT JS
Html Templating - DOT JS
 
Web Development basics with WordPress
Web Development basics with WordPressWeb Development basics with WordPress
Web Development basics with WordPress
 
The Importance Things of Full Stack Development
The Importance Things of Full Stack DevelopmentThe Importance Things of Full Stack Development
The Importance Things of Full Stack Development
 
Scaling Wordpress
Scaling WordpressScaling Wordpress
Scaling Wordpress
 
Top web development tools
Top web development toolsTop web development tools
Top web development tools
 
Web development
Web developmentWeb development
Web development
 
Introduction to Basic Concepts in Web
Introduction to Basic Concepts in WebIntroduction to Basic Concepts in Web
Introduction to Basic Concepts in Web
 
Thin Server Architecture SPA, 5 years old presentation
Thin Server Architecture SPA, 5 years old presentationThin Server Architecture SPA, 5 years old presentation
Thin Server Architecture SPA, 5 years old presentation
 
Introduction To Website Development
Introduction To Website DevelopmentIntroduction To Website Development
Introduction To Website Development
 
Client side vs server side
Client side vs server sideClient side vs server side
Client side vs server side
 
Web 2.0
Web 2.0Web 2.0
Web 2.0
 
Thin Server Architecture
Thin Server ArchitectureThin Server Architecture
Thin Server Architecture
 
Web development classes in pune
Web development classes in puneWeb development classes in pune
Web development classes in pune
 
Web deveplopment courses in pune
Web deveplopment courses  in puneWeb deveplopment courses  in pune
Web deveplopment courses in pune
 

Similar to Client side performance compromises worth making

Organize Your Website With Advanced CSS Tricks
Organize Your Website With Advanced CSS TricksOrganize Your Website With Advanced CSS Tricks
Organize Your Website With Advanced CSS TricksAndolasoft Inc
 
Building high performing web pages
Building high performing web pagesBuilding high performing web pages
Building high performing web pagesNilesh Bafna
 
Presentation about html5 css3
Presentation about html5 css3Presentation about html5 css3
Presentation about html5 css3Gopi A
 
Websites Unlimited - Pay Monthly Websites
Websites Unlimited - Pay Monthly WebsitesWebsites Unlimited - Pay Monthly Websites
Websites Unlimited - Pay Monthly Websiteswebsiteunlimited
 
Making Of PHP Based Web Application
Making Of PHP Based Web ApplicationMaking Of PHP Based Web Application
Making Of PHP Based Web ApplicationSachin Walvekar
 
Modern ux-workflow-presentation
Modern ux-workflow-presentationModern ux-workflow-presentation
Modern ux-workflow-presentationBrian Akpa
 
Intro to mobile web application development
Intro to mobile web application developmentIntro to mobile web application development
Intro to mobile web application developmentzonathen
 
Bootstrap for Beginners
Bootstrap for BeginnersBootstrap for Beginners
Bootstrap for BeginnersD'arce Hess
 
CSS3 and a brief introduction to Google Maps API v3
CSS3 and a brief introduction to Google Maps API v3 CSS3 and a brief introduction to Google Maps API v3
CSS3 and a brief introduction to Google Maps API v3 Jeffrey Barke
 
Static site best practices
Static site best practicesStatic site best practices
Static site best practicesAllanki Srinivas
 
Website Performance at Client Level
Website Performance at Client LevelWebsite Performance at Client Level
Website Performance at Client LevelConstantin Stan
 
What is LessCSS and its Detailed Explation - Xhtmlchop
What is LessCSS and its Detailed Explation - XhtmlchopWhat is LessCSS and its Detailed Explation - Xhtmlchop
What is LessCSS and its Detailed Explation - Xhtmlchopxhtmlchop
 
An Introduction to CSS Preprocessors (SASS & LESS)
An Introduction to CSS Preprocessors (SASS & LESS)An Introduction to CSS Preprocessors (SASS & LESS)
An Introduction to CSS Preprocessors (SASS & LESS)Folio3 Software
 
An Introduction to CSS Frameworks
An Introduction to CSS FrameworksAn Introduction to CSS Frameworks
An Introduction to CSS FrameworksAdrian Westlake
 
Top Front-End Frameworks For Your Web Development Projects.pdf
Top Front-End Frameworks For Your Web Development Projects.pdfTop Front-End Frameworks For Your Web Development Projects.pdf
Top Front-End Frameworks For Your Web Development Projects.pdfCalvinLee106
 

Similar to Client side performance compromises worth making (20)

Organize Your Website With Advanced CSS Tricks
Organize Your Website With Advanced CSS TricksOrganize Your Website With Advanced CSS Tricks
Organize Your Website With Advanced CSS Tricks
 
Building high performing web pages
Building high performing web pagesBuilding high performing web pages
Building high performing web pages
 
Presentation about html5 css3
Presentation about html5 css3Presentation about html5 css3
Presentation about html5 css3
 
WEB DEVELOPMENT
WEB DEVELOPMENTWEB DEVELOPMENT
WEB DEVELOPMENT
 
Websites Unlimited - Pay Monthly Websites
Websites Unlimited - Pay Monthly WebsitesWebsites Unlimited - Pay Monthly Websites
Websites Unlimited - Pay Monthly Websites
 
Making Of PHP Based Web Application
Making Of PHP Based Web ApplicationMaking Of PHP Based Web Application
Making Of PHP Based Web Application
 
Modern ux-workflow-presentation
Modern ux-workflow-presentationModern ux-workflow-presentation
Modern ux-workflow-presentation
 
Asp.Net Tips
Asp.Net TipsAsp.Net Tips
Asp.Net Tips
 
Intro to mobile web application development
Intro to mobile web application developmentIntro to mobile web application development
Intro to mobile web application development
 
Bootstrap for Beginners
Bootstrap for BeginnersBootstrap for Beginners
Bootstrap for Beginners
 
CSS3 and a brief introduction to Google Maps API v3
CSS3 and a brief introduction to Google Maps API v3 CSS3 and a brief introduction to Google Maps API v3
CSS3 and a brief introduction to Google Maps API v3
 
Static site best practices
Static site best practicesStatic site best practices
Static site best practices
 
NodeJs Frameworks.pdf
NodeJs Frameworks.pdfNodeJs Frameworks.pdf
NodeJs Frameworks.pdf
 
Website Performance at Client Level
Website Performance at Client LevelWebsite Performance at Client Level
Website Performance at Client Level
 
ashish ppt webd.pptx
ashish ppt webd.pptxashish ppt webd.pptx
ashish ppt webd.pptx
 
HTML CSS & Javascript
HTML CSS & JavascriptHTML CSS & Javascript
HTML CSS & Javascript
 
What is LessCSS and its Detailed Explation - Xhtmlchop
What is LessCSS and its Detailed Explation - XhtmlchopWhat is LessCSS and its Detailed Explation - Xhtmlchop
What is LessCSS and its Detailed Explation - Xhtmlchop
 
An Introduction to CSS Preprocessors (SASS & LESS)
An Introduction to CSS Preprocessors (SASS & LESS)An Introduction to CSS Preprocessors (SASS & LESS)
An Introduction to CSS Preprocessors (SASS & LESS)
 
An Introduction to CSS Frameworks
An Introduction to CSS FrameworksAn Introduction to CSS Frameworks
An Introduction to CSS Frameworks
 
Top Front-End Frameworks For Your Web Development Projects.pdf
Top Front-End Frameworks For Your Web Development Projects.pdfTop Front-End Frameworks For Your Web Development Projects.pdf
Top Front-End Frameworks For Your Web Development Projects.pdf
 

Recently uploaded

Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsAndrey Dotsenko
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 

Recently uploaded (20)

Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 

Client side performance compromises worth making

  • 1. Client Side Performance Compromises Worth Making Sydney Web Apps Group: 19.9.13 @cathyblabla
  • 2. What!!? Good client-side performance really is simple - smaller files, fewer HTTP requests, less DOM manipulation. Use YSlow and understand the rules it is based on. OK, so there are lots of tricky details that we could go into, like CSS selector performance, but is your site huge enough for things like that to make a difference? Probably not. So….
  • 3. Where to draw the line Where do you draw the line between good performance and maintainability? Class names like ‘a1’ to make your CSS files smaller? No way! But there some situations where ‘The Rules’ can and should be bent...
  • 4. Multiple sprite images Sprites allows us to download all our image assets in one request. If you use Compass, it’s sprite functionality makes this super simple. But all those disparate colour palettes add up, resulting in either a big 32bit PNG or degraded colour reproduction. The solution? Split up your sprites into similar colour groups and stick to a set pallette. It’s a few more HTTP requests but worth it.
  • 5. Like this... $green-sprites: sprite-map("sprites/green/*.png"); $grey-sprites: sprite-map("sprites/grey/*.png"); %mail-icon { background: sprite($grey-sprites, mail) no-repeat; &:hover { background: sprite($green-sprites, mail) no-repeat; } }
  • 6. Scaling images in HTML Ideally, we would only download images at the exact size they will be displayed, but your responsive site will probably call for fluid images to cater for different devices - what to do!? If you can, serve different sized images based on device categories then allow CSS scaling to take over.
  • 7. Choose image sizes that match your target devices closely and that are close to the upper end of your breakpoint to minimise image degradation. Include the served image’s width and height in your html to reduce the visible effect of reflows once your image is loaded.
  • 8. Load (most) scripts at the bottom of the page Inserting scripts at the end of your page stops script downloads from blocking the rest of your content. But long pages can result in a noticeable lag for script effects - while your overall page load time may be improved the users’ perception of load time could be affected.
  • 9. ...so should I load my scripts in <head> after all? One approach is to load your ‘must have’ scripts in the head, then load the rest at the bottom of the page. While this introduces some maintenance overhead, your page loads as fast as possible while also giving your users a seamless experience.
  • 10. Script loaders FTW! RequireJS is a script loader that present a unique solution to this problem. Out of the box, RequireJS loads modules asynchronously as they are called for. There is also an optimisation tool that provides an automated build. All the files required for your project are minified and concatenated, this file is then loaded asynchronously. Your scripts are optimised, available earlier and are non- blocking. Yay!
  • 11. What about lazy loading? It is possible to squeeze even more performance out of your Require scripts by splitting them up and lazy loading those that are less often needed. Read about it here. YUI includes a script loader that is based on RequireJS but also utilises a server side combo handler that serves back separate files in one request. The combo loader is open source and you can get it here.
  • 12. Some OO in your SASS Love the modular approach of OOCSS but don’ t like your HTML getting cluttered up with non semantic class names? With SASS you have the tools to write modular, concise code that can be constructed in any way you wish. Create a structural hierarchy within your SASS code and push design complexity back to the style layer to keep your HTML simple and readable.
  • 13. Use placeholders to create re-usable structures... %btn { @include rnd( 3px ); border: 1px solid grey; cursor: pointer; line-height: 2.3; padding: 0 17px; text-decoration: none; } .my-button { @extend %btn; color: green; }
  • 14. Build up top level rules from combinations of re-usables .news-module { @extend %media-block; @extend %media-module; .top-stories { @extend %stories-list; } .more-link { @extend %btn; } }
  • 15. Mixins give you more flexibility... @mixin button ($colour: green) { @include background-image( linear-gradient(white, $colour) ); border: 1px solid darken($colour, 40%); color: 1px solid lighten($colour, 20%); } .delete-button { @include button(red); } .active-button { @include button(blue); }
  • 16. But be careful of the final output... Placeholders generate a single rule with all selectors combined. If you have too many, IE goes kaboom! .btn1, .btn2, .btn { //styles extended from %btn } Mixin styles are repeated wherever they are used, so use them minimally, ideally for styles that are unique (ie, based on a parameter).
  • 17. .delete-button { background-image( linear-gradient(white, red) ); border: 1px solid #660000; color: 1px solid #FFBFBF; } .active-button { background-image( linear-gradient(white, blue) ); border: 1px solid #000066; color: 1px solid #99CCFF; }