Live data from Hacker News

Fragment.js - A tiny tool for loading html fragments and templates

danielrapp.github.com

1–10 of 14 posts

Re: Fragment.js - A tiny tool for loading html fragments and templates

#4
post #3

Super neat but I can't think of a scenario where I would need it. What was the reason you built this for?

Thanks! Originally I just wanted a way to add a src attribute to any element, I eventually realized that it could be used to finally fix my issues with templates; too much javascript scaffolding.

Re: Fragment.js - A tiny tool for loading html fragments and templates

#6
It's a nice fun little tool -- but it's rather inefficient in terms of the number of AJAX requests that it needs to do in order to fetch the templates. The rather simple linked page needs a total of 3 AJAX requests, one for each template. As your app (especially mobile apps) needs more templates, it probably won't be very performant. There's a reason why Ember and other frameworks prefer their templates to be embedded right in the HTML -- no need for separate AJAX fetching.

Re: Fragment.js - A tiny tool for loading html fragments and templates

#8
post #7

If you added a build process that actually pulled in the source files for a bundled production file you might have something similar to RequireJS for templates. Cool stuff.

Doesn't require.js include plugins that will pull in compiled templates for you for the major templating libraries already? (underscore, mustache etc)?

Re: Fragment.js - A tiny tool for loading html fragments and templates

#9
post #6

It's a nice fun little tool -- but it's rather inefficient in terms of the number of AJAX requests that it needs to do in order to fetch the templates. The rather simple linked page needs a total of 3 AJAX requests, one for each template. As your app (especially mobile apps) needs more templates, it probably won't be very performant. There's a reason why Ember and other frameworks prefer their templates to be embedde…

Default behavior for ngView in Angular is to fetch the template with Ajax. You have your view html files in a partials directory.
Post reply on HN