Skip to content

Instantly share code, notes, and snippets.

@lancejpollard
Created May 10, 2012 20:50
Show Gist options
  • Save lancejpollard/2655809 to your computer and use it in GitHub Desktop.
Save lancejpollard/2655809 to your computer and use it in GitHub Desktop.
Ember.js code that *will* cause performance problems

ember-views/view.js

Your element won't render until the next frame. This will cause a flash.

// Schedule the DOM element to be created and appended to the given
// element after bindings have synchronized.
this._insertElementLater(function() {
  this.$().appendTo(target);
});

Other performance problems

White flashes

  • when an Ember.CollectionView goes from full to empty and back and forth, it flashes. Is this because it's taking 2 frames?

Questions

  • what happens when you remove vs. destroy a view, are the bindings removed? are the bindings still executing?
  • how do you specify default values for a computed property?

Performance Optimizations

  • use detach in addition to remove, so you can keep the cached element if you are going to redraw it (http://api.jquery.com/detach/)
  • somehow make bindings stop working until an object is set from isVisible: false to isVisible: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment