Settings

Theme

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

danielrapp.github.com

34 points by DanielRapp 13 years ago · 13 comments

Reader

garindra 13 years ago

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.

  • Kiro 13 years ago

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

    • ZaneA 13 years ago

      I believe Angular will search for inline templates first, so as long as you use the same path for the template name it won't attempt any AJAX fetching.

ivansavz 13 years ago

Very nice.

This is functionnality very similar to http://www.aimath.org/knowlepedia/ but done much better.

example usage of knowl.js here (loads proofs inline) http://linear.ups.edu/html/section-HSE.html

tg3 13 years ago

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.

nateweiss 13 years ago

I like it, nice and simple way to include and render some data from an API or something. Thanks to the author for making it available.

g2e 13 years ago

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

  • DanielRappOP 13 years ago

    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.

itsbits 13 years ago

feel like its overhead for webApps..

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection