Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handlebars parsing slow-ish on Android Webkit #233

Closed
pamelafox opened this issue May 1, 2012 · 4 comments
Closed

Handlebars parsing slow-ish on Android Webkit #233

pamelafox opened this issue May 1, 2012 · 4 comments

Comments

@pamelafox
Copy link

I've been checking out the parse times for Handlebars in my Android PhoneGap app, and I'm seeing the longest times for Handlebars - in a range from 50 to 90 milliseconds. My app JS files are from 10-40ms, and other JS libs are 0-35. A screenshot of times for the last 2 runs is here: http://dl.dropbox.com/u/10998095/Screenshots/5m72gn3r8mqi.png

My measurement technique is simple, I log the time before and after the Handlebars.js script is parsed. The handlebars.js is part of a longer JS file, so the JS file has already been loaded by the time it starts parsing it - i.e. the 50-90ms should not include load time.

I haven't spent much time in the Handlebars code, so I hoped I could get some insight here as to where the extra parse time might be coming from - basically, what sort of things does Handlebars do besides function definitions when the code is first parsed?

I'm also surprised to see it vary so much, from 50-90, as most of the other JS libs are fairly consistent across runs, and it makes me wonder where the variance is from.

Thanks!

@wagenet
Copy link
Collaborator

wagenet commented May 1, 2012

You can, and probably should, precompile your Handlebars templates.

@pamelafox
Copy link
Author

Ah! Good point. I do pre-compile my templates, but I neglected to use the runtime build instead of the normal one. I'll make that substitution today and report on the results. Thanks for pointing that out.

@pamelafox
Copy link
Author

Confirmed that the runtime is much faster (5-10ms).

Small n00b request: It'd be nice if the handlebars-runtime in https://github.com/wycats/handlebars.js/downloads ended in ".js", as it took me a few minutes to figure out that it was a text file, not an archive (and my Mac had no idea).

@wagenet
Copy link
Collaborator

wagenet commented May 1, 2012

@pamelafox Looks like an accident, since beta5 has .js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants