Smashing WebKit
Jon Raasch
This edition first published 2011
2012 John Wiley & Sons, Ltd.
Registered office
John Wiley & Sons Ltd, The Atrium, Southern Gate, Chichester, West Sussex, PO19 8SQ, United Kingdom
For details of our global editorial offices, for customer services and for information about how to apply for permission to reuse the copyright material in this book please see our website at www.wiley.com.
The right of the author to be identified as the author of this work has been asserted in accordance with the Copyright, Designs and Patents Act 1988.
All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording or otherwise, except as permitted by the UK Copyright, Designs and Patents Act 1988, without the prior permission of the publisher.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books.
Designations used by companies to distinguish their products are often claimed as trademarks. All brand names and product names used in this book are trade names, service marks, trademarks or registered trademarks of their respective owners. The publisher is not associated with any product or vendor mentioned in this book. This publication is designed to provide accurate and authoritative information in regard to the subject matter covered. It is sold on the understanding that the publisher is not engaged in rendering professional services. If professional advice or other expert assistance is required, the services of a competent professional should be sought.
Trademarks: Wiley and the John Wiley & Sons, Ltd. logo are trademarks or registered trademarks of John Wiley & Sons, Ltd. and/ or its affiliates in the United States and/or other countries, and may not be used without written permission. All trademarks are the property of their respective owners. John Wiley & Sons, Ltd. is not associated with any product or vendor mentioned in the book.
Adobe: Copyright 2011 Adobe Systems Incorporated. All rights reserved.
Google: Android, Swiffy and Google Chrome are registered trademarks of Google Inc. Use of these trademarks is subject to Google Permissions.
Apple: iPhone, iPad and iPod are trademarks of Apple Computer, Inc. All other trademarks are the property of their respective owners. John Wiley & Sons, Ltd. is not associated with any product or vendor mentioned in the book. This book is not endorsed by Apple Computer, Inc.
WebKit: WebKit is open source software with portions licensed under the LGPL and BSD licenses. Complete license and copyright information can be found within the code.
978-1-119-99913-3
A catalogue record for this book is available from the British Library.
Set in 10/12 Minion Pro by Wiley Composition Services
Printed in United States by CJK
This album is dedicated to all the teachers who told me Id never amount to nothin.
Notorious B.I.G.
Publishers Acknowledgments
Some of the people who helped bring this book to market include the following:
Editorial and Production
VP Consumer and Technology Publishing Director: Michelle Leete
Associate DirectorBook Content Management: Martin Tribe
Associate Publisher: Chris Webb
Assistant Editor: Ellie Scott
Development Editor: Sydney Argenta
Copy Editor: Maryann Steinhart
Technical Editor: Steven Hoober
Editorial Manager: Jodi Jensen
Senior Project Editor: Sara Shlaer
Editorial Assistant: Leslie Saxman
Marketing
Associate Marketing Director: Louise Breinholt
Marketing Executive: Kate Parrett
Composition Services
Compositor: Indianapolis Composition Services
Proofreader: Susan Hobbs
Indexer: Potomac Indexing, LLC
About the Author
Jon Raasch is a freelance web developer specializing in frontend engineering with HTML5, CSS3 and JavaScript. A regular contributor to Smashing Magazine, he also writes on his personal blog at http://jonraasch.com/
.
Jon Raasch built his first website when he was 14. It was hosted on GeoCities and was particularly terrible. Now he builds cutting-edge websites and web-based applications using modern technologies. He is passionate about web standards, frontend performance and user-experience design.
Formerly based in Portland, OR, Jon now travels the world working remotely (with a particular fondness for Berlin, Germany).
Follow him on Twitter: http://twitter.com/jonraasch
.
Acknowledgments
Id like to thank Paul Irish for his suggestions for the performance chapter, and Estelle Weyl for her CSS-only iOS interface.
Otherwise, thanks to all the people who write tutorials, give talks on frontend development and release open-source software: Jonathan Snook, Stoyan Stefanov, Remy Sharp, Nicholas Zakas, David DeSandro, Nicole Sullivan, Peter-Paul Koch, Luke Wroblewski, Chris Coyier, Zoe Gillenwater, Christian Heilmann, Kyle Simpson, Steve Souders, Stephanie Rewis, Jacob Gube, Mathias Bynens, Bruce Lawson, Ethan Marcotte, Jan Lehnardt, Jed Schmidt, Nicolas Gallagher, Robert Nyman, Jake Archibald, Lea Verou, Ben Alman, David Kaneda and all the others Im forgetting.
Id also like to thank the Smashing Magazine team and Vitaly Friedman, as well as the editors at Wiley, especially Sydney Argenta and Steven Hoober. Finally, Id like to thank Kate Knappett for looking over Chapters 3 and 4.
When my editor approached me about writing a book on WebKit, I initially thought the topic was a bit strange. While I certainly love developing with the advanced features available in WebKit, websites are rarely confined to a single environment, and Ive never worked on a project that is geared towards only WebKit browsers.
But the more I thought about it, the more I realized how useful a book on WebKit could be. Thats because learning about this engine does not mean supporting only WebKit-based browsers. Rather, learning WebKit is about learning standards.
Several years ago, CSS3 features such as rounded corners and gradients were only available in the WebKit-based Safari. At that time, building a site with these features might have been a fun exercise, but certainly was not feasible for production websites.
Fast-forward to today, where most of those capabilities are now supported across all major browsers. CSS3 has gone from a fringe hobby for Safari nerds, to a mainstream approach used in major websites. Thats because the features that once originated in WebKit proved so useful that they became standards across all web development.
Today, WebKit continues to push rendering to the next level, innovating new features and sculpting the future of web development. Many of the CSS3 and HTML5 capabilities in WebKit have already been adopted by other browsers, and you can expect more to be adopted in the months and years to come.
Thus learning WebKit provides a window into the future of web development. In this rapidly evolving field, it is crucial for developers to keep on top of modern trends and practices. Focusing on WebKit allows you to go one step further, learning not only the technologies that are used today, but also those that will be used tomorrow.
So should you build websites only for WebKit? Definitely not.
While Smashing WebKit focuses on the capabilities of WebKit-based browsers, this engine is not studied in isolation. Whenever possible, cross-browser solutions are discussed, whether they are native support of universal web standards, or alternative workarounds that can be employed as graceful degradation.