SlideShare a Scribd company logo
SproutCore and
                            Performance


Wednesday, June 29, 2011
“                          One should not pursue goals
                           that are easily achieved. One
                           must develop an instinct for
                           what one can just barely
                           achieve through one’s greatest
                           efforts.


                                            Albert Einstein


Wednesday, June 29, 2011
"Fast By
                           Default"
Wednesday, June 29, 2011
Core
                           Concepts
Wednesday, June 29, 2011
1. JS is
                            cheaper
                           than DOM
Wednesday, June 29, 2011
2. Keep
                Intermediate
                 State in JS
Wednesday, June 29, 2011
(and out of
                        DOM)
Wednesday, June 29, 2011
3. Events
                            Cannot
                           Coalesce
Wednesday, June 29, 2011
(prefer
                            cache
                           clearing)
Wednesday, June 29, 2011
4. Materialize
                Objects
              When Used
Wednesday, June 29, 2011
(also, proxy,
                don't copy)
Wednesday, June 29, 2011
5. Follow
                        Speed
                       Guidelines
Wednesday, June 29, 2011
JS is
                            Cheaper
                           than DOM
Wednesday, June 29, 2011
change name          change DOM

                           change title   change DOM

                 change address           change DOM




Wednesday, June 29, 2011
change name

                           change title   change DOM

                 change address




Wednesday, June 29, 2011
change name

                    change title   change DOM

              change address




Wednesday, June 29, 2011
SC
                                      run
                                     loop




                           browser
                            event
                             loop




Wednesday, June 29, 2011
handle event
               native                       sync
                           handle event
               event                      bindings
                           handle event




Wednesday, June 29, 2011
handle event
               native                       sync
                           handle event
               event                      bindings
                           handle event




Wednesday, June 29, 2011
handle event
               native                       sync
                           handle event
               event                      bindings
                           handle event




Wednesday, June 29, 2011
Event Handling

                               JS Code

                               JS Code

                               JS Code

                                  ...

                               DOM Code


Wednesday, June 29, 2011
Keep
           Intermediate
            State in JS
Wednesday, June 29, 2011
Case Study

Wednesday, June 29, 2011
“
Wednesday, June 29, 2011
                           I want to have a view that
                           displays the total number of
                           items that are marked done.

                           I want to have a feature that
                           can mark all remaining items
                           done.
What do you want to do?
                      4 items remaining


                             Mark All Done

                             Wash dishes
                             Take out garbage
                             Make bed
                             Relax


Wednesday, June 29, 2011
What do you want to do?
                      4 items remaining


                             Mark All Done

                       ✓ Wash dishes
                             Take out garbage
                             Make bed
                             Relax


Wednesday, June 29, 2011
What do you want to do?
                      3 items remaining


                             Mark All Done

                       ✓ Wash dishes
                             Take out garbage
                             Make bed
                             Relax


Wednesday, June 29, 2011
What do you want to do?
                      3 items remaining


                             Mark All Done

                       ✓ Wash dishes
                             Take out garbage
                             Make bed
                             Relax


Wednesday, June 29, 2011
What do you want to do?
                      3 items remaining


                       ✓ Mark All Done
                       ✓ Wash dishes
                             Take out garbage
                             Make bed
                             Relax


Wednesday, June 29, 2011
What do you want to do?
                      0 items remaining


                       ✓ Mark All Done
                       ✓ Wash dishes
                       ✓ Take out garbage
                       ✓ Make bed
                       ✓ Relax

Wednesday, June 29, 2011
"KVO"

Wednesday, June 29, 2011
item marked done



                           re-render stats view




Wednesday, June 29, 2011
Backbone
          window.AppView = Backbone.View.extend({
            initialize: function() {
              _.bindAll(this, 'addOne', 'addAll', 'render');
              this.input    = this.$("#new-todo");
              Todos.bind('add',     this.addOne);
              Todos.bind('refresh', this.addAll);
              Todos.bind('all',     this.render);
              Todos.fetch();
            },
           
            render: function() {
              var done = Todos.done().length;
              this.$('#todo-stats').html(this.statsTemplate({
                total:      Todos.length,
                done:       Todos.done().length,
                remaining:  Todos.remaining().length
              }));
            }
          });


Wednesday, June 29, 2011
Backbone

          window.TodoList = Backbone.Collection.extend({
            done: function() {
              return this.filter(function(todo){
                return todo.get('done');
              });
            },
             
            remaining: function() {
              return this.without.apply(this, this.done());
            }
          });
           
          window.Todos = new TodoList;




Wednesday, June 29, 2011
Toggling




          Todos.forEach(function(todo) {
            todo.toggle();
          });




Wednesday, June 29, 2011
item marked done

                           compute remaining
                                               xN
                             compute done

                           render stats view




Wednesday, June 29, 2011
This is
            foundational
Wednesday, June 29, 2011
No notion of
           intermediate
               state
Wednesday, June 29, 2011
Prefer
                   Coalescing
                   Operations
Wednesday, June 29, 2011
SproutCore




          ArrayController.create({
            content: [],

            remaining: function() {
              return this.filterProperty('isDone', false);
            }.property('@each.isDone')
          });




Wednesday, June 29, 2011
Superficially
               Similar
Wednesday, June 29, 2011
intermediate state
                            item marked done
                                                   xN
                           clear remaining cache


                                      run loop

                            compute remaining

                             render stats view

Wednesday, June 29, 2011
Easy to
                           Overlook
Wednesday, June 29, 2011
SproutCore




          ArrayController.create({
            content: [],

            remaining: function() {
              return this.filterProperty('isDone', false);
            }.property('@each.isDone')
          });




Wednesday, June 29, 2011
Key:
                           Declare
                            Intent
Wednesday, June 29, 2011
"Coalesce"

Wednesday, June 29, 2011
Wrong

Wednesday, June 29, 2011
A         B

                           "hello"   "hello"




Wednesday, June 29, 2011
A     B

                           "1"   "1"




Wednesday, June 29, 2011
A      B

                           "12"   "12"




Wednesday, June 29, 2011
A       B

                           "123"   "123"




Wednesday, June 29, 2011
Right

Wednesday, June 29, 2011
A         B

                           "hello"   "hello"




Wednesday, June 29, 2011
A       B

                           "1"   "hello"




Wednesday, June 29, 2011
A       B

                           "12"   "hello"




Wednesday, June 29, 2011
A        B

                           "123"   "hello"




Wednesday, June 29, 2011
A                   B
                                   run loop
                           "123"              "hello"




Wednesday, June 29, 2011
A       B

                           "123"   "123"




Wednesday, June 29, 2011
Not 3
                           Deferred
                           Observers
Wednesday, June 29, 2011
Materialize
                   Objects
                  When Used
Wednesday, June 29, 2011
Large JSON Structure



          {
            contacts: [
              { name: "Yehuda", ... },
              ... x 10,000
            ]
          }



Wednesday, June 29, 2011
Acre, Julie
                           Appleseed, Johnny
                           Arrow, Bob
                           Astels, David
                           Atwood, Michael
                           Axelrod, Peter
                           Azeroth, Roy



Wednesday, June 29, 2011
Contact
                     Data Store   on demand   name
                                              title
              (JSON Hashes)                   address
                                              telephone




Wednesday, June 29, 2011
Ajax Response




                                         RecordArray
                     Data Store   live
                                          Contacts
                                         where
              (JSON Hashes)              company =
                                         "GOOGLE"




Wednesday, June 29, 2011
{
                      Contact       name: "yehuda"
                                    title: "Chief Technologist"
                 data               address: "690 Spruce"
                 status             telephone: "718.877.1325"
                                }




Wednesday, June 29, 2011
No Need to
                     Copy
                   Properties
Wednesday, June 29, 2011
Again,
              Foundational
Wednesday, June 29, 2011
One More
                            Thing
Wednesday, June 29, 2011
Page Speed

Wednesday, June 29, 2011
Build Tools

Wednesday, June 29, 2011
Packed Files

Wednesday, June 29, 2011
CDN:
                           Versioned
                             URLs
Wednesday, June 29, 2011
Expires
                           Header:
                            Same
Wednesday, June 29, 2011
Stylesheets
                  at the Top
Wednesday, June 29, 2011
Scripts at
                   the Bottom
Wednesday, June 29, 2011
Simple
                           Layout
Wednesday, June 29, 2011
External JS
                   and CSS
Wednesday, June 29, 2011
Minification

Wednesday, June 29, 2011
Easier said
                    than done
Wednesday, June 29, 2011
SproutCore
                     2.0
Wednesday, June 29, 2011
Matters, but not as much
        as you think.




                            Overall
                           File Size
Wednesday, June 29, 2011
Modules w/
                 Declared
                  Deps
Wednesday, June 29, 2011
Lazy
                           Loading
                           Modules
Wednesday, June 29, 2011
Thank you.

Wednesday, June 29, 2011
Questions

Wednesday, June 29, 2011

More Related Content

Similar to Writing Fast Client-Side Code: Lessons Learned from SproutCore

Distribute the workload, PHPTek, Amsterdam, 2011
Distribute the workload, PHPTek, Amsterdam, 2011Distribute the workload, PHPTek, Amsterdam, 2011
Distribute the workload, PHPTek, Amsterdam, 2011
Helgi Þormar Þorbjörnsson
 
開発者のためのiPhone⇔Androidアプリ移植のポイント
開発者のためのiPhone⇔Androidアプリ移植のポイント開発者のためのiPhone⇔Androidアプリ移植のポイント
開発者のためのiPhone⇔Androidアプリ移植のポイント
yoski
 
Getting Involved in the Drupal Community
Getting Involved in the Drupal CommunityGetting Involved in the Drupal Community
Getting Involved in the Drupal Communitykarschsp
 
Carla diana sketching11
Carla diana sketching11Carla diana sketching11
Carla diana sketching11
Carla Diana
 
Wibiya founders at The Junction
Wibiya founders at The JunctionWibiya founders at The Junction
Wibiya founders at The JunctionDaniel Tal
 
Envato Dev Ops - Alt.Net Melbourne
Envato Dev Ops - Alt.Net MelbourneEnvato Dev Ops - Alt.Net Melbourne
Envato Dev Ops - Alt.Net Melbourne
John Barton
 

Similar to Writing Fast Client-Side Code: Lessons Learned from SproutCore (7)

Distribute the workload, PHPTek, Amsterdam, 2011
Distribute the workload, PHPTek, Amsterdam, 2011Distribute the workload, PHPTek, Amsterdam, 2011
Distribute the workload, PHPTek, Amsterdam, 2011
 
開発者のためのiPhone⇔Androidアプリ移植のポイント
開発者のためのiPhone⇔Androidアプリ移植のポイント開発者のためのiPhone⇔Androidアプリ移植のポイント
開発者のためのiPhone⇔Androidアプリ移植のポイント
 
Getting Involved in the Drupal Community
Getting Involved in the Drupal CommunityGetting Involved in the Drupal Community
Getting Involved in the Drupal Community
 
Carla diana sketching11
Carla diana sketching11Carla diana sketching11
Carla diana sketching11
 
Wibiya founders at The Junction
Wibiya founders at The JunctionWibiya founders at The Junction
Wibiya founders at The Junction
 
Himanshu pbe
Himanshu pbeHimanshu pbe
Himanshu pbe
 
Envato Dev Ops - Alt.Net Melbourne
Envato Dev Ops - Alt.Net MelbourneEnvato Dev Ops - Alt.Net Melbourne
Envato Dev Ops - Alt.Net Melbourne
 

More from Yehuda Katz

SproutCore: Amber
SproutCore: AmberSproutCore: Amber
SproutCore: Amber
Yehuda Katz
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the FinishYehuda Katz
 
Why You Shouldn't Write OO
Why You Shouldn't Write OO Why You Shouldn't Write OO
Why You Shouldn't Write OO Yehuda Katz
 
Vaporware To Awesome
Vaporware To AwesomeVaporware To Awesome
Vaporware To AwesomeYehuda Katz
 
Merb Day Keynote
Merb Day KeynoteMerb Day Keynote
Merb Day KeynoteYehuda Katz
 
Merb jQuery
Merb jQueryMerb jQuery
Merb jQuery
Yehuda Katz
 
Merb Camp Keynote
Merb Camp KeynoteMerb Camp Keynote
Merb Camp Keynote
Yehuda Katz
 
Merb
MerbMerb
DataMapper
DataMapperDataMapper
DataMapper
Yehuda Katz
 
jQuery and Ruby Web Frameworks
jQuery and Ruby Web FrameworksjQuery and Ruby Web Frameworks
jQuery and Ruby Web Frameworks
Yehuda Katz
 
jQuery Presentation to Rails Developers
jQuery Presentation to Rails DevelopersjQuery Presentation to Rails Developers
jQuery Presentation to Rails Developers
Yehuda Katz
 

More from Yehuda Katz (12)

SproutCore: Amber
SproutCore: AmberSproutCore: Amber
SproutCore: Amber
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the Finish
 
Why You Shouldn't Write OO
Why You Shouldn't Write OO Why You Shouldn't Write OO
Why You Shouldn't Write OO
 
Vaporware To Awesome
Vaporware To AwesomeVaporware To Awesome
Vaporware To Awesome
 
Merb Day Keynote
Merb Day KeynoteMerb Day Keynote
Merb Day Keynote
 
Testing Merb
Testing MerbTesting Merb
Testing Merb
 
Merb jQuery
Merb jQueryMerb jQuery
Merb jQuery
 
Merb Camp Keynote
Merb Camp KeynoteMerb Camp Keynote
Merb Camp Keynote
 
Merb
MerbMerb
Merb
 
DataMapper
DataMapperDataMapper
DataMapper
 
jQuery and Ruby Web Frameworks
jQuery and Ruby Web FrameworksjQuery and Ruby Web Frameworks
jQuery and Ruby Web Frameworks
 
jQuery Presentation to Rails Developers
jQuery Presentation to Rails DevelopersjQuery Presentation to Rails Developers
jQuery Presentation to Rails Developers
 

Recently uploaded

20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
Pixlogix Infotech
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Zilliz
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
ThomasParaiso2
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 

Recently uploaded (20)

20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 

Writing Fast Client-Side Code: Lessons Learned from SproutCore

  • 1. SproutCore and Performance Wednesday, June 29, 2011
  • 2. One should not pursue goals that are easily achieved. One must develop an instinct for what one can just barely achieve through one’s greatest efforts. Albert Einstein Wednesday, June 29, 2011
  • 3. "Fast By Default" Wednesday, June 29, 2011
  • 4. Core Concepts Wednesday, June 29, 2011
  • 5. 1. JS is cheaper than DOM Wednesday, June 29, 2011
  • 6. 2. Keep Intermediate State in JS Wednesday, June 29, 2011
  • 7. (and out of DOM) Wednesday, June 29, 2011
  • 8. 3. Events Cannot Coalesce Wednesday, June 29, 2011
  • 9. (prefer cache clearing) Wednesday, June 29, 2011
  • 10. 4. Materialize Objects When Used Wednesday, June 29, 2011
  • 11. (also, proxy, don't copy) Wednesday, June 29, 2011
  • 12. 5. Follow Speed Guidelines Wednesday, June 29, 2011
  • 13. JS is Cheaper than DOM Wednesday, June 29, 2011
  • 14. change name change DOM change title change DOM change address change DOM Wednesday, June 29, 2011
  • 15. change name change title change DOM change address Wednesday, June 29, 2011
  • 16. change name change title change DOM change address Wednesday, June 29, 2011
  • 17. SC run loop browser event loop Wednesday, June 29, 2011
  • 18. handle event native sync handle event event bindings handle event Wednesday, June 29, 2011
  • 19. handle event native sync handle event event bindings handle event Wednesday, June 29, 2011
  • 20. handle event native sync handle event event bindings handle event Wednesday, June 29, 2011
  • 21. Event Handling JS Code JS Code JS Code ... DOM Code Wednesday, June 29, 2011
  • 22. Keep Intermediate State in JS Wednesday, June 29, 2011
  • 24. “ Wednesday, June 29, 2011 I want to have a view that displays the total number of items that are marked done. I want to have a feature that can mark all remaining items done.
  • 25. What do you want to do? 4 items remaining Mark All Done Wash dishes Take out garbage Make bed Relax Wednesday, June 29, 2011
  • 26. What do you want to do? 4 items remaining Mark All Done ✓ Wash dishes Take out garbage Make bed Relax Wednesday, June 29, 2011
  • 27. What do you want to do? 3 items remaining Mark All Done ✓ Wash dishes Take out garbage Make bed Relax Wednesday, June 29, 2011
  • 28. What do you want to do? 3 items remaining Mark All Done ✓ Wash dishes Take out garbage Make bed Relax Wednesday, June 29, 2011
  • 29. What do you want to do? 3 items remaining ✓ Mark All Done ✓ Wash dishes Take out garbage Make bed Relax Wednesday, June 29, 2011
  • 30. What do you want to do? 0 items remaining ✓ Mark All Done ✓ Wash dishes ✓ Take out garbage ✓ Make bed ✓ Relax Wednesday, June 29, 2011
  • 32. item marked done re-render stats view Wednesday, June 29, 2011
  • 33. Backbone window.AppView = Backbone.View.extend({   initialize: function() {     _.bindAll(this, 'addOne', 'addAll', 'render');     this.input    = this.$("#new-todo");     Todos.bind('add',     this.addOne);     Todos.bind('refresh', this.addAll);     Todos.bind('all',     this.render);     Todos.fetch();   },     render: function() {     var done = Todos.done().length;     this.$('#todo-stats').html(this.statsTemplate({       total:      Todos.length,       done:       Todos.done().length,       remaining:  Todos.remaining().length     }));   } }); Wednesday, June 29, 2011
  • 34. Backbone window.TodoList = Backbone.Collection.extend({   done: function() {     return this.filter(function(todo){       return todo.get('done');     });   },       remaining: function() {     return this.without.apply(this, this.done());   } });   window.Todos = new TodoList; Wednesday, June 29, 2011
  • 35. Toggling Todos.forEach(function(todo) {   todo.toggle(); }); Wednesday, June 29, 2011
  • 36. item marked done compute remaining xN compute done render stats view Wednesday, June 29, 2011
  • 37. This is foundational Wednesday, June 29, 2011
  • 38. No notion of intermediate state Wednesday, June 29, 2011
  • 39. Prefer Coalescing Operations Wednesday, June 29, 2011
  • 40. SproutCore ArrayController.create({   content: [],   remaining: function() {     return this.filterProperty('isDone', false);   }.property('@each.isDone') }); Wednesday, June 29, 2011
  • 41. Superficially Similar Wednesday, June 29, 2011
  • 42. intermediate state item marked done xN clear remaining cache run loop compute remaining render stats view Wednesday, June 29, 2011
  • 43. Easy to Overlook Wednesday, June 29, 2011
  • 44. SproutCore ArrayController.create({   content: [],   remaining: function() {     return this.filterProperty('isDone', false);   }.property('@each.isDone') }); Wednesday, June 29, 2011
  • 45. Key: Declare Intent Wednesday, June 29, 2011
  • 48. A B "hello" "hello" Wednesday, June 29, 2011
  • 49. A B "1" "1" Wednesday, June 29, 2011
  • 50. A B "12" "12" Wednesday, June 29, 2011
  • 51. A B "123" "123" Wednesday, June 29, 2011
  • 53. A B "hello" "hello" Wednesday, June 29, 2011
  • 54. A B "1" "hello" Wednesday, June 29, 2011
  • 55. A B "12" "hello" Wednesday, June 29, 2011
  • 56. A B "123" "hello" Wednesday, June 29, 2011
  • 57. A B run loop "123" "hello" Wednesday, June 29, 2011
  • 58. A B "123" "123" Wednesday, June 29, 2011
  • 59. Not 3 Deferred Observers Wednesday, June 29, 2011
  • 60. Materialize Objects When Used Wednesday, June 29, 2011
  • 61. Large JSON Structure {   contacts: [     { name: "Yehuda", ... },     ... x 10,000   ] } Wednesday, June 29, 2011
  • 62. Acre, Julie Appleseed, Johnny Arrow, Bob Astels, David Atwood, Michael Axelrod, Peter Azeroth, Roy Wednesday, June 29, 2011
  • 63. Contact Data Store on demand name title (JSON Hashes) address telephone Wednesday, June 29, 2011
  • 64. Ajax Response RecordArray Data Store live Contacts where (JSON Hashes) company = "GOOGLE" Wednesday, June 29, 2011
  • 65. { Contact name: "yehuda" title: "Chief Technologist" data address: "690 Spruce" status telephone: "718.877.1325" } Wednesday, June 29, 2011
  • 66. No Need to Copy Properties Wednesday, June 29, 2011
  • 67. Again, Foundational Wednesday, June 29, 2011
  • 68. One More Thing Wednesday, June 29, 2011
  • 72. CDN: Versioned URLs Wednesday, June 29, 2011
  • 73. Expires Header: Same Wednesday, June 29, 2011
  • 74. Stylesheets at the Top Wednesday, June 29, 2011
  • 75. Scripts at the Bottom Wednesday, June 29, 2011
  • 76. Simple Layout Wednesday, June 29, 2011
  • 77. External JS and CSS Wednesday, June 29, 2011
  • 79. Easier said than done Wednesday, June 29, 2011
  • 80. SproutCore 2.0 Wednesday, June 29, 2011
  • 81. Matters, but not as much as you think. Overall File Size Wednesday, June 29, 2011
  • 82. Modules w/ Declared Deps Wednesday, June 29, 2011
  • 83. Lazy Loading Modules Wednesday, June 29, 2011