HNHacker News
TopNewBestAskShowJobs

frontendbeauty

389 karma · joined November 23, 2011

submissionscomments
frontendbeauty··on Our First Node.js App: Backbone on the Client and Server
Exactly.
frontendbeauty··on Our First Node.js App: Backbone on the Client and Server
I'm open to that. Like I've said, there's definitely room for cleanup of the implementation. Either way, this isn't a detail that's exposed to the application developer.
frontendbeauty··on Our First Node.js App: Backbone on the Client and Server
It sounds like you are really questioning the usefulness of client-side JS apps in general. Certainly not every app makes sense to be a "single-page app". But if you are creating a single-page app, then why not also allow it to render on the server?

I like to think of Rendr as just another Backbone app, that happens to be able to serve HTML from the server as well.

frontendbeauty··on Our First Node.js App: Backbone on the Client and Server
While the library (Rendr) is written in CoffeeScript, you would of course be able to write your application code in JavaScript, or anything that compiles down to it.
frontendbeauty··on Our First Node.js App: Backbone on the Client and Server
Author here. So, yes, bootstrapping the JSON on initial pageload would be a lot faster than waiting for the Backbone.Router to fetch it (for the Rails + Backbone approach). But therein lies the problem I was talking about: to bootstrap the data for a particular URL, but to also have the client-side request the proper data for that URL in response to a pushState event, you end up needing to duplicate the mappings from app URLs to API resources on the client- and server-sides, and you need to be able to access the same API on both sides as well.

We avoid this with Rendr by defining routes, controllers, models, etc in a way that can be run on both sides.

frontendbeauty··on Our First Node.js App: Backbone on the Client and Server
Agreed, the underscore in the data-attribute isn't ideal. I initially tried to use camelCase, but alas, we often forget that DOM elements are case-insensitive:

http://cl.ly/image/2c113k1h1L41

frontendbeauty··on Our First Node.js App: Backbone on the Client and Server
Author here (spikebrehm). Good question. Yep, you could accomplish something similar by booting up PhantomJS or node-chimera [0] and scraping yourself, but that seems hacky and hard to scale. Justin Tulloss of Rdio talked about this approach in his Airbnb Tech Talk [1], saying that the tricky part is determining when the page is actually done rendering, especially if you have a bunch of JavaScript that's performing DOM manipulation.

[0] https://github.com/deanmao/node-chimera [1] https://www.youtube.com/watch?v=TB-l2nF67iU

frontendbeauty··on Our First Node.js App: Backbone on the Client and Server
Author here (spikebrehm):

Jeremy, I think you're mistaking this for Keith Norman's SpainJS presentation (http://www.youtube.com/watch?v=jbn9c_yfuoM). He proposes the same approach, but I don't know if it ever got past a demo. Although it seems like they may be using some form of this at Groupon in production.

Anyway, it is exciting, isn't it? This is just the beginning for us -- we've had to make a few hacky design decisions to be able to ship, but I think we will get the kinks worked out. The trick, and the challenge, seems to lie in choosing the right set of abstractions to hide the code complexity from the application developer. I hope to open source it as soon as I can, to benefit from the input of luminaries such as yourself!

Oh yeah, and the offer to give a Tech Talk at Airbnb next time you're in SF still stands :)

frontendbeauty··on Our First Node.js App: Backbone on the Client and Server
The author (spikebrehm) speaking here - that's a good observation! It's possible that the user will click on a link before the JS finishes downloading. Luckily, we've taken care to use real URLs for all links, and our pages render fully on the server as well, so if they click before the Backbone views initialize, they will fall through to the server. Not the fastest experience, but still fine at the end of the day.
frontendbeauty··on Airbnb Releases Infinity.js: A Javascript Library for Smoother Scrolling
Awesome! This is going to help so much.
frontendbeauty··on Try the konami code on Airbnb
false
← PreviousPage 2 of 2