Slides: http://davidbcalhoun.com/present/mobile-performance/
http://www.meetup.com/SF-Web-Performance-Group/events/16116764








/*
Screens bigger than 480px
*/
@media only screen and (min-width: 481px) {
#header { background-image: url(header-full.png); }
}
/*
Screens smaller than 480px
*/
@media only screen and (max-width: 480px) {
#header { background-image: url(header-small.png); }
}
Instead of simply downscaling images, serve lower-bandwidth versions where it makes sense.
<html class="no-mediaqueries"> (a la Modernizr) and target it with CSS (.no-mediaqueries {background-image: url(really-small-image.png);})/* High dpi */
@media only screen and (min-resolution: 300dpi),
only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (min--moz-device-pixel-ratio: 1.5) {
#header { background-image: url(header-300dpi.png); }
}
/* Low dpi */
@media only screen and (max-resolution: 299dpi),
only screen and (-webkit-max-device-pixel-ratio: 1.5),
only screen and (max--moz-device-pixel-ratio: 1.5) {
#header { background-image: url(header-72dpi.png); }
}
Nicer experience at the cost of performance.


navigator.connectionJavaScript object available in Android 2.2+
navigator = {
connection: {
"type": "4",
"UNKNOWN": "0",
"ETHERNET": "1",
"WIFI": "2",
"CELL_2G": "3",
"CELL_3G": "4"
}
};
navigator.connection: JS var connection, connectionSpeed, htmlNode, htmlClass;
connection = navigator.connection || {"type":"0"}; // fallback
switch(connection.type) {
case connection.CELL_3G: connectionSpeed = "mediumbandwidth"; break;
case connection.CELL_2G: connectionSpeed = "lowbandwidth"; break;
default: connectionSpeed = 'highbandwidth';
}
/* set the connection speed on the html element
i.e. <html class="lowbandwidth">
*/
htmlNode = document.body.parentNode;
htmlClass = htmlNode.getAttribute("class") || "";
htmlNode.setAttribute("class", htmlClass + " " + connectionSpeed);
Drop this in <head>!
navigator.connection: CSS.highbandwidth .logo { background-image:url('logo-high.jpg'); }
.mediumbandwidth .logo { background-image:url('logo-medium.jpg'); }
.lowbandwidth .logo { background-image:url('logo-low.jpg'); }

foo.js:

Lots of JS loaded up front
= UI thread, user interaction is blocked while processing
More recent progress: Nicholas Zakas's <noexecute> attribute proposal for scripts




= slow download, laggy interaction
Nice tool: DOM Monster (http://mir.aculo.us/dom-monster/)
BUT don't go overboard. Don't add translate3d on everything.. your GPU is not all-powerful!
