2

I am using Ember.js to build a website for my company.

The problem I am having is that the initial load time of the page is around 10 seconds.

I cant give you the profiling data from chrome because I can't get them out of work. However what I noticed when looking at them is that there is a function called "Get" which takes in total around 8.5 seconds. I realize this is probably just many uses of Ember.Get(), but still this is just the initial page load.

I don't know if this is normal or not but it's extremely unpleasant. Is there something I can do about this?

Thanks, Jason

mr.soroush
  • 1,110
  • 2
  • 14
  • 31
Jason
  • 4,034
  • 4
  • 40
  • 62

1 Answers1

4

try using a production release (the minified version of ember.js), it uses a significantly faster get.

Are you rendering some very large lists? If so look into using List View.

If you have a ton of fields being bound that don't ever change modify them to be unbound.

{{unbound someField}}

If you are having some weird issue where a template is taking a long time, yet you aren't sure which one it is, you can add some timestamp logging to the beginning of your templates to track down the culprit. At the bottom I whipped up a quick helper. In your template you could use it like so. It will print out a timestamp with that data point passed in.

{{logTime this}}
{{logTime name}} 



Ember.Handlebars.helper('logTime', function(someField){
  var d = new Date,
    timestamp = d.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1") + "." + d.getMilliseconds();
  console.log(timestamp + " - " + text);
  return "";
 });
Kingpin2k
  • 47,277
  • 10
  • 78
  • 96
  • Thanks for the optimization tips, I will try to use the minified version at work tomorrow. And for my large list I am using ember-table. however when the application loads the tables are empty. So that is not a factor. So what bothers me is that I have very little binding and data when my application first loads (just some empty views - all the data is filled later when I subscribe) and its still very slow to load.. – Jason Jul 30 '13 at 16:16
  • If you watch the network tab while it's loading, does it give a little more insight into what's taking so long to load? It's a little confusing because we're binding probably 200+ fields with probably 7 outlets and 10+ views in under a second. – Kingpin2k Jul 31 '13 at 00:06
  • I should mention, I was talking about the network tab in chrome dev tools. Are you using chrome/ie/ff? – Kingpin2k Jul 31 '13 at 00:07
  • When I looked at the network tab it said most of the time is spent "Scripting" so I recorded the JavaScript profile until the page loaded and what I reported above is what I noticed. I will spend more time on this issue today, see what I can come up with. – Jason Jul 31 '13 at 05:39
  • Is there some really large data sets? Some sort of recursive dependency issue? You could also do some additionally logging to try and figure out which template may be the culprit. I'll include some code in my original answer above. – Kingpin2k Jul 31 '13 at 06:01
  • Thanks for all the help, What solved my problem in the end was upgrading chrome at my work from 25 to 28. Seems there are bugs with ember.js at older versions of chrome – Jason Aug 02 '13 at 06:48