4 ms·
Why is everyone so afraid of HTML that they insist on starting projects like this? I've seen them come and go for 15+ years now and they're never useful. Even
by Zelphyr 14y ago
Why is everyone so afraid of HTML that they insist on starting projects like this? I've seen them come and go for 15+ years now and they're never useful. Even less so in the case of using JS to generate HTML because that makes the browser actually work harder.
This isn't a knock against OP or the project creator (if they're not one and the same) because projects like these can be useful exercises. But I would never use something like this in production and I would hope nobody else would either.
- grimtrigger 14y agoI work on an enterprise platform where I have client side access, but no server side access. My only options for injecting HTML are: 1) cross domain AJAX via CORS 2) Injecting HTML strings constructed in JS For small amounts of HTML, I'd much rather go with option #2. ps. Its unfortunately very common for developers to have little or no server side access to the applications they're building.
- crescentfresh 14y agoWait, are you rolling up all client templating libraries into 2) or something?
- grimtrigger 14y agoMy understanding of "client templating libraries" is that they sit on the server, and create code that will be delivered to the client. For example moustache. If you can easily avoid a call to the server, it might be a good idea.
- bsimpson 14y agoClient side templating libraries like Handlebars do in the browser what server side libraries like Jinja do in the cloud. You've described server-side libraries. Client-side do the exact same thing in JS on the client.
- hellerbarde 14y agoWhat do you mean by "afraid of HTML"? I haven't used this yet, so bear that in mind, but to me this seems to be something that is more expressive than html (I meant String) concatenation. That leads, in my experience, to better maintainability and thus less worries in the future. Whether this impacts JS performance enough to be a problem, I don't know and don't have the time to test right now. Edit: words are hard... I accidentally a few of them.
- nobodysfool 14y agoPerformance impact should be minimal. It's only 200 lines of code, and it uses string concatenation internally. Still, I see no benefit to using this rather than doing a document.createElement('div') and assigning the attributes / contents. Perhaps it's a bit faster than using document.createElement. There may be bugs in this one, as it doesn't escape attributes.