Mastering JavaScript High Performance

Book Description

Master the art of building, deploying, and optimizing faster web applications with JavaScript

In Detail

Studying JavaScript performance in depth will make you capable of tackling the complex and important tasks required to solve performance issues. In this book, you'll learn when and why to use an IDE over a common text editor. Packed with examples, you'll also learn how to create a build system to test and deploy your JavaScript project by optimizing the code. Next, you will move on to learn about DOM optimization, JavaScript promises, and web workers to better break up your large codebase. You will also learn about JavaScript performance on mobile platforms such as iOS and Android and how to deploy your JavaScript project to a device. Finally, by the end of the book, you'll be able to pinpoint JavaScript performance problems using appropriate tools, provide optimization techniques, and provide tools to develop fast applications with JavaScript.

What You Will Learn

  • Test existing JavaScript code using JSLint and understand how to better optimize JavaScript code
  • Create your own build system for JavaScript projects using Node.js and GulpJS
  • Get to know best performance-focused practices when writing JavaScript code
  • Use the DOM more efficiently by optimizing JavaScript with CSS3 animations
  • Learn how to unit test JavaScript code using Jasmine

Table of Contents

  1. Mastering JavaScript High Performance
    1. Table of Contents
    2. Mastering JavaScript High Performance
    3. Credits
    4. About the Author
    5. About the Reviewers
      1. Support files, eBooks, discount offers, and more
        1. Why subscribe?
        2. Free access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Downloading the color images of this book
        3. Errata
        4. Piracy
        5. Questions
    8. 1. The Need for Speed
      1. Weren't websites always fast?
        1. Getting faster
        2. Selecting an effective editor
          1. Integrated Development Environments
            1. The Microsoft Visual Studio IDE
            2. JetBrain's WebStorm IDE
          2. Mid-range editors
            1. Panic's Coda editor
            2. The Microsoft WebMatrix editor
          3. Lightweight editors
            1. The Sublime Text editor
            2. The Notepad++ editor
          4. Cloud-based editors
            1. The Cloud9 editor
            2. The Codenvy editor
      2. Summary
    9. 2. Increasing Code Performance with JSLint
      1. Checking the JavaScript code performance
        1. About the console time API
        2. When to use console.time
      2. What is JavaScript linting?
        1. About JSLint
        2. Using JSLint
        3. Reviewing errors
        4. Configuring messy white space
        5. Understanding the use strict statement
        6. Using console in JSLint
      3. Summary
    10. 3. Understanding JavaScript Build Systems
      1. What is a build system?
        1. Compiling code by example
        2. Error-checking in a JavaScript build system
        3. Adding optimization beyond coding standards
        4. Creating a build system from scratch using Gulp.js
          1. Node.js
            1. Testing a Node.js installation
            2. Testing Node Package Manager's installation
              1. About Node Package Manager
              2. Checking NPM installation in the Terminal
              3. The basics of using NPM
            3. Installing jQuery with NPM
      2. Setting up our build system
        1. About Grunt.js and Gulp.js
          1. Grunt Task Runner
          2. About Gulp
            1. Installing Gulp
            2. Creating a gulpfile
            3. Running a Gulp project
        2. Integrating JSLint into Gulp
        3. Testing our example file
        4. Creating a distribution
      3. Summary
    11. 4. Detecting Performance
      1. Web Inspectors in general
        1. The Safari Web Inspector
        2. Firefox Developer tools
        3. Internet Explorer developer tools
        4. Chrome's Developer tools
          1. Getting familiar with Chrome's Developer tools
            1. The Elements panel
            2. The Network panel
            3. The Sources panel
              1. Debugger basic usage
                1. Testing the debugger
                2. Using the debugger keyword
            4. The Timeline panel
              1. Using the Timeline panel
              2. The Loading event
              3. The Scripting event
              4. The Rendering event
              5. The Painting event
            5. The Profile panel
            6. The Resources panel
            7. The Audits panel
              1. Interacting with the Audits panel
              2. Getting Suggestions for JavaScript quality
            8. The Console panel
      2. Summary
    12. 5. Operators, Loops, and Timers
      1. Operators
        1. The comparison operator
          1. Is strict faster?
      2. Loops
        1. How loops affect performance
        2. The reverse loop performance myth
      3. Timers
        1. What are timers and how do they affect performance?
          1. Working around single-threading
          2. Closing the loop
      4. Summary
    13. 6. Constructors, Prototypes, and Arrays
      1. Building with constructors and instance functions
        1. A quick word
        2. The care and feeding of function names
        3. Understanding instances
          1. Creating instances with 'new'
      2. Alternate constructor functions using prototypes
        1. Understanding prototypes in terms of memory
        2. Which is faster, a prototype or a constructor function?
      3. Array performance
        1. Optimizing array searches
      4. Summary
    14. 7. Hands off the DOM
      1. Why worry about the DOM?
      2. Don't we need an MV-whatever library?
      3. Creating new objects using the createElement function
        1. Working around the createElement function
        2. Working with the createElement function
        3. When to use the createElement function?
      4. Animating elements
        1. Animating the old-fashioned way
        2. Animating using CSS3
        3. An unfair performance advantage
      5. Understanding paint events
        1. How to check for paint events?
        2. Testing paint events
      6. Pesky mouse scrolling events
      7. Summary
    15. 8. Web Workers and Promises
      1. Understanding the limitations first
      2. Web workers
        1. Testing workers with a local server
      3. Promises
        1. Testing a true asynchronous promise
      4. Summary
    16. 9. Optimizing JavaScript for iOS Hybrid Apps
      1. Getting ready for iOS development
      2. iOS hybrid development
        1. Setting up a simple iOS hybrid app
        2. Using Safari Web Inspector for JavaScript performance
        3. Comparing UIWebView with Mobile Safari
        4. Common ways to improve hybrid performance
        5. The WKWebView framework
      3. Summary
    17. 10. Application Performance Testing
      1. What is unit testing in JavaScript?
      2. Unit testing with Jasmine
        1. Installation and configuration
        2. Reviewing the project code base
        3. Reviewing an application's spec for writing tests
        4. Writing tests using Jasmine
        5. Fixing our code
      3. Summary
    18. Index

Product Information

  • Title: Mastering JavaScript High Performance
  • Author(s): Chad R. Adams
  • Release date: March 2015
  • Publisher(s): Packt Publishing
  • ISBN: 9781784397296