Secrets of the Javascript Ninja

Total Page:16

File Type:pdf, Size:1020Kb

Secrets of the Javascript Ninja Secrets of the JavaScript Ninja JOHN RESIG BEAR BIBEAULT MANNING SHELTER ISLAND For online information and ordering of this and other Manning books, please visit www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact Special Sales Department Manning Publications Co. 20 Baldwin Road PO Box 261 Shelter Island, NY 11964 Email: [email protected] ©2013 by Manning Publications Co. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps. Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end. Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15 percent recycled and processed without the use of elemental chlorine. Manning Publications Co. Development editors: Jeff Bleiel, Sebastian Stirling 20 Baldwin Road Technical editor: Valentin Crettaz PO Box 261 Copyeditor: Andy Carroll Shelter Island, NY 11964 Proofreader: Melody Dolab Typesetter: Dennis Dalinnik Cover designer: Leslie Haimes ISBN: 978-1-933988-69-6 Printed in the United States of America 1 2 3 4 5 6 7 8 9 10 – MAL – 18 17 16 15 14 13 12 brief contents PART 1 PREPARING FOR TRAINING. ...........................................1 1 ■ Enter the ninja 3 2 ■ Arming with testing and debugging 13 PART 2 APPRENTICE TRAINING ................................................29 3 ■ Functions are fundamental 31 4 ■ Wielding functions 61 5 ■ Closing in on closures 89 6 ■ Object-orientation with prototypes 119 7 ■ Wrangling regular expressions 151 8 ■ Taming threads and timers 175 PART 3 NINJA TRAINING........................................................191 9 ■ Ninja alchemy: runtime code evaluation 193 10 ■ With statements 215 11 ■ Developing cross-browser strategies 229 12 ■ Cutting through attributes, properties, and CSS 253 iii iv BRIEF CONTENTS PART 4 MASTER TRAINING.....................................................287 13 ■ Surviving events 289 14 ■ Manipulating the DOM 329 15 ■ CSS selector engines 345 contents preface xi acknowledgments xiii about this book xv about the authors xx PART 1 PREPARING FOR TRAINING . ...............................1 Enter the ninja 3 1 1.1 The JavaScript libraries we’ll be tapping 4 1.2 Understanding the JavaScript language 5 1.3 Cross-browser considerations 6 1.4 Current best practices 9 Current best practice: testing 9 ■ Current best practice: performance analysis 10 1.5 Summary 11 Arming with testing and debugging 13 2 2.1 Debugging code 14 Logging 14 ■ Breakpoints 16 v vi CONTENTS 2.2 Test generation 17 2.3 Testing frameworks 19 QUnit 21 ■ YUI Test 22 ■ JsUnit 22 Newer unit-testing frameworks 22 2.4 The fundamentals of a test suite 22 The assertion 23 ■ Test groups 24 ■ Asynchronous testing 25 2.5 Summary 27 PART 2 APPRENTICE TRAINING.....................................29 Functions are fundamental 31 3 3.1 What’s with the functional difference? 32 Why is JavaScript’s functional nature important? 33 Sorting with a comparator 37 3.2 Declarations 40 Scoping and functions 43 3.3 Invocations 46 From arguments to function parameters 47 ■ Invocation as a function 49 ■ Invocation as a method 50 ■ Invocation as a constructor 52 ■ Invocation with the apply() and call() methods 54 3.4 Summary 58 Wielding functions 61 4 4.1 Anonymous functions 62 4.2 Recursion 64 Recursion in named functions 64 ■ Recursion with methods 65 The pilfered reference problem 66 ■ Inline named functions 68 The callee property 70 4.3 Fun with function as objects 71 Storing functions 72 ■ Self-memoizing functions 73 Faking array methods 76 4.4 Variable-length argument lists 77 Using apply() to supply variable arguments 77 Function overloading 79 4.5 Checking for functions 86 4.6 Summary 88 CONTENTS vii Closing in on closures 89 5 5.1 How closures work 90 5.2 Putting closures to work 94 Private variables 94 ■ Callbacks and timers 96 5.3 Binding function contexts 99 5.4 Partially applying functions 103 5.5 Overriding function behavior 106 Memoization 106 ■ Function wrapping 109 5.6 Immediate functions 111 Temporary scope and private variables 112 ■ Loops 115 Library wrapping 117 5.7 Summary 118 Object-orientation with prototypes 119 6 6.1 Instantiation and prototypes 120 Object instantiation 120 ■ Object typing via constructors 127 Inheritance and the prototype chain 128 HTML DOM prototypes 133 6.2 The gotchas! 135 Extending Object 135 ■ Extending Number 136 Subclassing native objects 137 ■ Instantiation issues 139 6.3 Writing class-like code 143 Checking for function serializability 146 ■ Initialization of subclasses 147 ■ Preserving super-methods 148 6.4 Summary 150 Wrangling regular expressions 151 7 7.1 Why regular expressions rock 152 7.2 A regular expression refresher 153 Regular expressions explained 153 ■ Terms and operators 154 7.3 Compiling regular expressions 158 7.4 Capturing matching segments 161 Performing simple captures 161 ■ Matching using global expressions 162 ■ Referencing captures 163 Non-capturing groups 165 7.5 Replacing using functions 166 viii CONTENTS 7.6 Solving common problems with regular expressions 168 Trimming a string 168 ■ Matching newlines 170 Unicode 171 ■ Escaped characters 172 7.7 Summary 172 Taming threads and timers 175 8 8.1 How timers and threading work 176 Setting and clearing timers 176 ■ Timer execution within the execution thread 177 ■ Differences between timeouts and intervals 179 8.2 Minimum timer delay and reliability 180 8.3 Dealing with computationally expensive processing 183 8.4 Central timer control 186 8.5 Asynchronous testing 189 8.6 Summary 190 PART 3 NINJA TRAINING ............................................191 Ninja alchemy: runtime code evaluation 193 9 9.1 Code evaluation mechanisms 194 Evaluation with the eval() method 194 ■ Evaluation via the Function constructor 197 ■ Evaluation with timers 197 Evaluation in the global scope 198 ■ Safe code evaluation 199 9.2 Function “decompilation” 201 9.3 Code evaluation in action 204 Converting JSON 204 ■ Importing namespaced code 205 JavaScript compression and obfuscation 206 ■ Dynamic code rewriting 208 ■ Aspect-oriented script tags 209 Metalanguages and DSLs 210 9.4 Summary 213 With statements 215 10 10.1 What’s with “with”? 216 Referencing properties within a with scope 216 ■ Assignments within a with scope 218 ■ Performance considerations 219 10.2 Real-world examples 221 10.3 Importing namespaced code 223 CONTENTS ix 10.4 Testing 223 10.5 Templating with “with” 224 10.6 Summary 227 Developing cross-browser strategies 229 11 11.1 Choosing which browsers to support 230 11.2 The five major development concerns 231 Browser bugs and differences 232 ■ Browser bug fixes 233 Living with external code and markup 234 Missing features 239 ■ Regressions 240 11.3 Implementation strategies 242 Safe cross-browser fixes 242 ■ Object detection 243 Feature simulation 245 ■ Untestable browser issues 247 11.4 Reducing assumptions 249 11.5 Summary 251 Cutting through attributes, properties, and CSS 253 12 12.1 DOM attributes and properties 255 Cross-browser naming 256 ■ Naming restrictions 257 Differences between XML and HTML 257 ■ Behavior of custom attributes 258 ■ Performance considerations 258 12.2 Cross-browser attribute issues 262 DOM id/name expansion 262 ■ URL normalization 264 The style attribute 265 ■ The type attribute 265 The tab index problem 266 ■ Node names 267 12.3 Styling attribute headaches 267 Where are my styles? 268 ■ Style property naming 270 The float style property 271 ■ Conversion of pixel values 271 Measuring heights and widths 272 ■ Seeing through opacity 276 ■ Riding the color wheel 279 12.4 Fetching computed styles 282 12.5 Summary 285 PART 4 MASTER TRAINING .........................................287 Surviving events 289 13 13.1 Binding and unbinding event handlers 290 13.2 The Event object 294 x CONTENTS 13.3 Handler management 297 Centrally storing associated information 298 Managing event handlers 300 13.4 Triggering events 309 Custom events 310 13.5 Bubbling and delegation 315 Delegating events to an ancestor 315 ■ Working around browser deficiencies 316 13.6 The document ready event 324 13.7 Summary 326 Manipulating the DOM 329 14 14.1 Injecting HTML into the DOM 330 Converting HTML to DOM 331 ■ Inserting into the document 334 ■ Script execution 336 14.2 Cloning elements 338 14.3 Removing elements 340 14.4 Text contents 341 Setting text 342 ■ Getting text 343 14.5 Summary 344 CSS selector engines 345 15 15.1 The W3C Selectors API 347 15.2 Using XPath to find elements 349 15.3 The pure-DOM implementation 351 Parsing the selector 353 ■ Finding the elements 354 Filtering the set 355 ■ Recursing and merging 356 Bottom-up selector engine 357 15.4 Summary 359 index 361 preface When I started writing Secrets of the JavaScript Ninja years ago, in early 2008, I saw a real need: there were no books providing in-depth coverage of the most important parts of the JavaScript language (functions, closures, and prototypes), nor were there any books that covered the writing of cross-browser code. Unfortunately, the situation has not improved much, which is surprising. More and more development energy is being put into new technologies, such as the ones coming out of HTML5 or the new versions of ECMAScript. But there isn’t any point to diving into new technologies, or using the hottest libraries, if you don’t have a proper understanding of the fundamental characteristics of the JavaScript language.
Recommended publications
  • Changing the Game: Monthly Technology Briefs
    the way we see it Changing the Game: Monthly Technology Briefs April 2011 Tablets and Smartphones: Levers of Disruptive Change Read the Capgemini Chief Technology Officers’ Blog at www.capgemini.com/ctoblog Public the way we see it Tablets and Smartphones: Levers of Disruptive Change All 2010 shipment reports tell the same story - of an incredible increase in the shipments of both Smartphones and Tablets, and of a corresponding slowdown in the conventional PC business. Smartphone sales exceeded even the most optimis- tic forecasts of experts, with a 74 percent increase from the previous year – around a battle between Apple and Google Android for supremacy at the expense of traditional leaders Nokia and RIM BlackBerry. It was the same story for Tablets with 17.4 million units sold in 2010 led by Apple, but once again with Google Android in hot pursuit. Analyst predictions for shipments suggest that the tablet market will continue its exponential growth curve to the extent that even the usually cautious Gartner think that by 2013 there will be as many Tablets in use in an enterprise as PCs with a profound impact on the IT environment. On February 7, as part of the Gartner ‘First Thing Monday’ series under the title ‘The Digital Natives are Restless, The impending Revolt against the IT Nanny State’ Gartner analyst Jim Shepherd stated; “I am regularly hearing middle managers and even senior executives complaining bit- terly about IT departments that are so focussed on the global rollout of some monolith- ic solution that they have no time for new and innovative technologies that could have an immediate impact on the business.
    [Show full text]
  • Pragmatic Guide to Javascript
    www.allitebooks.com What Readers Are Saying About Pragmatic Guide to J a v a S c r i p t I wish I had o w n e d this book when I first started out doing JavaScript! Prag- matic Guide to J a v a S c r i p t will take you a big step ahead in programming real-world JavaScript by showing you what is going on behind the scenes in popular JavaScript libraries and giving you no-nonsense advice and back- ground information on how to do the right thing. W i t h the condensed years of e x p e r i e n c e of one of the best JavaScript developers around, it’s a must- read with great reference to e v e r y d a y JavaScript tasks. Thomas Fuchs Creator of the script.aculo.us framework An impressive collection of v e r y practical tips and tricks for getting the most out of JavaScript in today’s browsers, with topics ranging from fundamen- tals such as form v a l i d a t i o n and JSON handling to application e x a m p l e s such as mashups and geolocation. I highly recommend this book for anyone wanting to be more productive with JavaScript in their web applications. Dylan Schiemann CEO at SitePen, cofounder of the Dojo T o o l k i t There are a number of JavaScript books on the market today, b u t most of them tend to focus on the new or inexperienced JavaScript programmer.
    [Show full text]
  • Opera Software the Best Browsing Experience on Any Device
    Opera Software The best browsing experience on any device The best Internet experience on any device Web Standards for the Future – Bruce Lawson, Opera.com • Web Evangelist, Opera • Tech lead, Law Society & Solicitors Regulation Authority (2004-8) • Author 2 books on Web Standards, edited 2 • Committee member for British Standards Institution (BSI) for the new standard for accessible websites • Member of Web Standards Project: Accessibility Task Force • Member of W3C Mobile Best Practices Working Group Web Standards for the Future – Bruce Lawson, Opera.com B.A., Honours English Literature and Language with Drama Theresa is blind But she can use the Web if made with standards The big picture WWW The big picture Western Western Web A web (pre)history • 1989 TBL proposes a project • 1992 <img> in Mosaic beta. Now 99.57% (MAMA) • 1994 W3C started at MIT • 1996 The Browser Wars • 1999 WAP, Web Content Accessibility Guidelines (WCAG) • 2000 Flash Modern web history • 2000-ish .com Crash - Time to grow up... • 2002 Opera Mobile with Small Screen Rendering • 2005 WHAT-WG founded, W3C Mobile Web Initiative starts • 2007 W3C adopts WHAT-WG spec as basis for HTML 5 • January 22, 2008 First public working draft of HTML 5 Standards at Opera • 25 employees work on standards • Mostly at W3C - a big player • Working on many standards • Bringing new work to W3C • Implementing Standards properly (us and you!) (Web Standards Curriculum www.opera.com/wsc) Why standards? The Web works everywhere - The Web is the platform • Good standards help developers: validate; separate content and presentation - means specialisation and maintainability.
    [Show full text]
  • Expanding the Power of Csound with Integrated Html and Javascript
    Michael Gogins. Expanding the Power of Csound with Intergrated HTML and JavaScript EXPANDING THE POWER OF CSOUND WITH INTEGRATED HTML AND JAVA SCRIPT Michael Gogins [email protected] https://michaelgogins.tumblr.com http://michaelgogins.tumblr.com/ This paper presents recent developments integrating Csound [1] with HTML [2] and JavaScript [3, 4]. For those new to Csound, it is a “MUSIC N” style, user- programmable software sound synthesizer, one of the first yet still being extended, written mostly in the C language. No synthesizer is more powerful. Csound can now run in an interactive Web page, using all the capabilities of current Web browsers: custom widgets, 2- and 3-dimensional animated and interactive graphics canvases, video, data storage, WebSockets, Web Audio, mathematics typesetting, etc. See the whole list at HTML5 TEST [5]. Above all, the JavaScript programming language can be used to control Csound, extend its capabilities, generate scores, and more. JavaScript is the “glue” that binds together the components and capabilities of HTML5. JavaScript is a full-featured, dynamically typed language that supports functional programming and prototype-based object- oriented programming. In most browsers, the JavaScript virtual machine includes a just- in-time compiler that runs about 4 times slower than compiled C, very fast for a dynamic language. JavaScript has limitations. It is single-threaded, and in standard browsers, is not permitted to access the local file system outside the browser's sandbox. But most musical applications can use an embedded browser, which bypasses the sandbox and accesses the local file system. HTML Environments for Csound There are two approaches to integrating Csound with HTML and JavaScript.
    [Show full text]
  • Research-Based Comparison of Top20 Javascript Frameworks & Libraries Picked by Remote Developers in 2020
    Research-Based Comparison of Top20 JavaScript Frameworks & Libraries Picked by Remote Developers in 2020 Original # of Websites # of Devs Used Top 3 Countries with # of # of Ranking on # of Open Average JS Frameworks/ # of Stars Average Dev Type Founded by Release Ideal for Size Powered by a It (2019, the Highest % of Contributors Forks on Stack Overflow Vacancies on Hourly Rate Learnability Libraries on GitHub Salary (USA) Year Framework Worldwide) Usage on GitHub GitHb (2019) LinkedIn (USA) US React JavaScript library Facebook 2011 UI 133KB 380,164 71.7% Russia 146,000 1,373 28,300 1 130,300 $91,000.00 $35.19 Moderate Germany US Single-page apps and dynamic web Angular Front-end framework Google 2016 566KB 706,489 21.9% UK 59,000 1,104 16,300 2 94,282 $84,000.00 $39.14 Moderate apps Brazil US Vue.js Front-end framework Evan You 2014 UI and single-page applications 58.8KB 241,б615 40.5% Russia 161,000 291 24,300 5 27,395 $116,562.00 $42.08 Easy Germany US Ember.js Front-end framework Yehuda Katz 2011 Scalable single-page web apps 435KB 20,985 3.6% Germany 21,400 782 4,200 8 3,533 $105,315.00 $51.00 Difficult UK US Scalable web, mobile and desktop Meteor App platform Meteor Software 2012 4.2MB 8,674 4% Germany 41,700 426 5,100 7 256 $96,687.00 $27.92 Moderate apps France US JavaScript runtime Network programs, such as Web Node.js Ryan Dahl 2009 141KB 1,610,630 49.9% UK 69,000 2,676 16,600 not included 52,919 $104,964.00 $33.78 Moderate (server) environment servers Germany US Polymer JS library Google 2015 Web apps using web components
    [Show full text]
  • Readme for 3Rd Party Software FIN Framework
    Smart Infrastructure Note to Resellers: Please pass on this document to your customer to avoid license breach and copyright infringements. Third-Party Software Information for FIN Framework 5.0.7 J2 Innovations Inc. is a Siemens company and is referenced herein as SIEMENS. This product, solution or service ("Product") contains third-party software components listed in this document. These components are Open Source Software licensed under a license approved by the Open Source Initiative (www.opensource.org) or similar licenses as determined by SIEMENS ("OSS") and/or commercial or freeware software components. With respect to the OSS components, the applicable OSS license conditions prevail over any other terms and conditions covering the Product. The OSS portions of this Product are provided royalty-free and can be used at no charge. If SIEMENS has combined or linked certain components of the Product with/to OSS components licensed under the GNU LGPL version 2 or later as per the definition of the applicable license, and if use of the corresponding object file is not unrestricted ("LGPL Licensed Module", whereas the LGPL Licensed Module and the components that the LGPL Licensed Module is combined with or linked to is the "Combined Product"), the following additional rights apply, if the relevant LGPL license criteria are met: (i) you are entitled to modify the Combined Product for your own use, including but not limited to the right to modify the Combined Product to relink modified versions of the LGPL Licensed Module, and (ii) you may reverse-engineer the Combined Product, but only to debug your modifications.
    [Show full text]
  • BTEC 2012 Specification
    Diploma in Digital Applications Specification Pearson Edexcel Level 2 Diploma in Digital Applications (DiDA) From October 2014 Contents Qualification title and Qualification Number 1 Introduction 2 Key features 2 Rationale 2 Aims 3 Progression 3 Recommended prior knowledge, skills and understanding 3 Qualification structure 4 Pearson Edexcel Level 2 Diploma in Digital Applications (DiDA) 4 Assessment Objectives 4 Assessment Objective weightings for the Pearson Edexcel Level 2 Diploma in Digital Applications (DiDA) 5 Assessment summary 6 Availability of assessment 6 Unit structure 7 Units 9 Unit 1: Developing Web Products 11 Unit 2: Creative Multimedia 21 Unit 3: Artwork and Imaging 41 Unit 4: Game Making 61 Unit 5: Coding for the Web 79 Assessment information for the externally assessed unit 90 Sample assessment materials 90 Language of assessment 90 Assessment information for internally assessed units 91 Controls for task setting 91 Controls for task taking 91 Authentication 93 Submission of work to the teacher 93 Marking, standardisation and moderation 93 Security and backups 93 Language of assessment 94 Further information 94 Grading information 95 Qualification awards 95 Grade descriptors 95 Additional information 97 Registration and entry 97 Unit codes 97 Cash-in codes 97 Availability of assessment 98 Resitting of units 98 Awarding and reporting 98 Forbidden combinations and classification code 98 Access and recruitment 99 Access to qualifications for students with disabilities or specific needs 100 Further information and useful publications 101 Teacher support 101 Annexe A: Mapping to Key Stage 4 Computing Programme of Study 103 Annexe B: DiDA and Synoptic Assessment 105 Annexe C: Centre assessor sheets 107 Qualification title and Qualification Number Qualification Pearson Edexcel Level 2 Diploma in Digital title Applications Qualification 601/4650/3 Number (QN) This qualification is on the National Qualifications Framework (NQF).
    [Show full text]
  • Introducing HTML5 Second Edition
    HTMLINTRODUCING SECOND 5EDITION BRUCE LAWSON REMY SHARP Introducing HTML5, Second Edition Bruce Lawson and Remy Sharp New Riders 1249 Eighth Street Berkeley, CA 94710 510/524-2178 510/524-2221 (fax) Find us on the Web at: www.newriders.com To report errors, please send a note to [email protected] New Riders is an imprint of Peachpit, a division of Pearson Education Copyright © 2012 by Remy Sharp and Bruce Lawson Project Editor: Michael J. Nolan Development Editor: Margaret S. Anderson/Stellarvisions Technical Editors: Patrick H. Lauke (www.splintered.co.uk), Robert Nyman (www.robertnyman.com) Production Editor: Cory Borman Copyeditor: Gretchen Dykstra Proofreader: Jan Seymour Indexer: Joy Dean Lee Compositor: Danielle Foster Cover Designer: Aren Howell Straiger Cover photo: Patrick H. Lauke (splintered.co.uk) Notice of Rights All rights reserved. No part of this book may be reproduced or transmitted in any form by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission of the publisher. For informa- tion on getting permission for reprints and excerpts, contact permissions@ peachpit.com. Notice of Liability The information in this book is distributed on an “As Is” basis without war- ranty. While every precaution has been taken in the preparation of the book, neither the authors nor Peachpit shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the instructions contained in this book or by the com- puter software and hardware products described in it. Trademarks Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks.
    [Show full text]
  • John Resig About Me
    Coder Day of Service John Resig About Me • Lots of Open Source work • jQuery, Processing.js, other projects! • Worked at Mozilla (Non-profit, Open Source) • Working at Khan Academy (Non-profit, free content, some Open Source) jQuery Beginnings • Library for making JavaScript easier to write. • Created it in 2005 • While I was in college! • I hated cross-browser inconsistencies • Also really dis-liked the DOM jQuery’s Growth • Released in 2006 • Slowly grew for many years • Started to explode in 2009 • Drupal, Microsoft, Wordpress, Adobe all use jQuery • Currently used by 70% of the top 10,000 web sites on the web. Full-time • From 2009 to 2011 got funding from Mozilla (my employer) • Worked on jQuery full-time! • Built up the jQuery Foundation (non-profit) Letting Go • Decided to step down to focus on building applications • Moved to Khan Academy! • jQuery Foundation runs everything now • They do a really good job :) Open Source/Open Data Tips Don’t be try to be perfect. Non-code things are just as important as code. Your community will mimic you. Benefits of Open Source/Open Data You use Open Source, why not give back? People will do projects you don’t have time for. You’ll attract interesting developers. ...which can lead to hiring good developers! Khan Academy Stats • 3 million problems practiced per day • 300 million lessons delivered • 100,000 educators around the world • 10 million students per month Khan API • Access to all data and user info • (with proper authentication) • You can access: • Videos + video data • All nicely organized • Exercise data • Student logs Data Analysis iPhone Application Exercises Exercises Exercise Racer Museums and Libraries Museums and Libraries • Cultural institutions • (Typically) Free for all • (Typically) Non-profits • They can use our help! Ukiyo-e.org Helping Public Institutions • Brooklyn Museum • New York Public Library • Digital Public Library of America • ...and many more! • All have public, free, open, APIs!.
    [Show full text]
  • Secrets of the Javascript Ninja.Pdf
    MEAP Edition Manning Early Access Program Copyright 2008 Manning Publications For more information on this and other Manning titles go to www.manning.com Contents Preface Part 1 JavaScript language Chapter 1 Introduction Chapter 2 Functions Chapter 3 Closures Chapter 4 Timers Chapter 5 Function prototype Chapter 6 RegExp Chapter 7 with(){} Chapter 8 eval Part 2 Cross-browser code Chapter 9 Strategies for cross-browser code Chapter 10 CSS Selector Engine Chapter 11 DOM modification Chapter 12 Get/Set attributes Chapter 13 Get/Set CSS Chapter 14 Events Chapter 15 Animations Part 3 Best practices Chapter 16 Unit testing Chapter 17 Performance analysis Chapter 18 Validation Chapter 19 Debugging Chapter 20 Distribution 1 Introduction Authorgroup John Resig Legalnotice Copyright 2008 Manning Publications Introduction In this chapter: Overview of the purpose and structure of the book Overview of the libraries of focus Explanation of advanced JavaScript programming Theory behind cross-browser code authoring Examples of test suite usage There is nothing simple about creating effective, cross-browser, JavaScript code. In addition to the normal challenge of writing clean code you have the added complexity of dealing with obtuse browser complexities. To counter-act this JavaScript developers frequently construct some set of common, reusable, functionality in the form of JavaScript library. These libraries frequently vary in content and complexity but one constant remains: They need to be easy to use, be constructed with the least amount of overhead, and be able to work in all browsers that you target. It stands to reason, then, that understanding how the very best JavaScript libraries are constructed and maintained can provide great insight into how your own code can be constructed.
    [Show full text]
  • Mechanizing Webassembly Proposals
    University of Wisconsin Milwaukee UWM Digital Commons Theses and Dissertations August 2020 Mechanizing Webassembly Proposals Jacob Richard Mischka University of Wisconsin-Milwaukee Follow this and additional works at: https://dc.uwm.edu/etd Part of the Computer Sciences Commons Recommended Citation Mischka, Jacob Richard, "Mechanizing Webassembly Proposals" (2020). Theses and Dissertations. 2565. https://dc.uwm.edu/etd/2565 This Thesis is brought to you for free and open access by UWM Digital Commons. It has been accepted for inclusion in Theses and Dissertations by an authorized administrator of UWM Digital Commons. For more information, please contact [email protected]. MECHANIZING WEBASSEMBLY PROPOSALS by Jacob Mischka A Dissertation Submitted in Partial Fulfillment of the Requirements for the degree of Master of Science in Computer Science at The University of Wisconsin-Milwaukee August 2020 ABSTRACT MECHANIZING WEBASSEMBLY PROPOSALS by Jacob Mischka The University of Wisconsin-Milwaukee, 2020 Under the Supervision of Professor John Boyland WebAssembly is a modern low-level programming language designed to provide high performance and security. To enable these goals, the language specifies a relatively small number of low-level types, instructions, and lan- guage constructs. The language is proven to be sound with respect to its types and execution, and a separate mechanized formalization of the specifi- cation and type soundness proofs confirms this. As an emerging technology, the language is continuously being developed, with modifications being pro- posed and discussed in the open and on a frequent basis. ii In order to ensure the soundness properties exhibited by the original core language are maintained as WebAssembly evolves, these proposals should too be mechanized and verified to be sound.
    [Show full text]
  • Notices: License License Text Libraries Copyright Notices
    This application uses certain open source software. As required by the terms of the open source license applicable to such open source software, we are providing you with the following notices: License License Text Libraries Copyright Notices ISC ISC License Copyright (c) 2004-2010 by Internet abab-1.0.4.tgz Copyright © 2019 W3C and Jeff Carpenter Systems Consortium, Inc. ("ISC") Copyright (c) Isaac Z. Schlueter and Copyright (c) 1995-2003 by Internet Software abbrev-1.1.1.tgz Consortium Contributors Copyright Isaac Z. Schlueter Permission to use, copy, modify, and /or distribute anymatch-2.0.0.tgz Copyright 2014 Elan Shanker this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all Copyright 2019 Elan Shanker, Paul Miller anymatch-3.1.1.tgz copies. (https://paulmillr.com) THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING aproba-1.2.0.tgz Copyright 2015 Rebecca Turner ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY are-we-there-yet-1.1.5.tgz Copyright 2015 Rebecca Turner SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, ast-types-flow-0.0.7.tgz Copyright (c) 2018 Kyle Davis NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. block-stream-0.0.9.tgz Copyright Isaac Z Copyright Isaac
    [Show full text]