StackShareStackShare
Follow on
StackShare

Discover and share technology stacks from companies around the world.

Follow on

© 2025 StackShare. All rights reserved.

Product

  • Stacks
  • Tools
  • Feed

Company

  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Service
  1. Stackups
  2. Application & Data
  3. Templating Languages & Extensions
  4. Templating Languages And Extensions
  5. Handlebars.js vs Underscore

Handlebars.js vs Underscore

OverviewDecisionsComparisonAlternatives

Overview

Handlebars.js
Handlebars.js
Stacks8.3K
Followers3.2K
Votes308
Underscore
Underscore
Stacks1.9K
Followers589
Votes290
GitHub Stars27.4K
Forks5.5K

Handlebars.js vs Underscore: What are the differences?

Introduction

Handlebars.js and Underscore are both popular JavaScript libraries commonly used in web development. While they share some similarities, there are several key differences between the two that developers should be aware of. This Markdown code provides a brief comparison of Handlebars.js and Underscore, highlighting their main distinctions.

  1. Syntax and Templating: Handlebars.js is primarily a templating engine that allows for dynamic content rendering. It provides a simple and intuitive syntax, utilizing custom delimiters (such as {{}}) for injecting data into HTML templates. On the other hand, Underscore focuses more on manipulating and iterating over data with a functional programming approach, offering utilities like map, filter, and reduce functions.

  2. Template Rendering: Handlebars.js operates by taking a template and binding it to data, which can then be rendered as HTML. It excels at rendering complex templates with custom logic and partials, making it a popular choice for rendering dynamic content. In contrast, Underscore does not have built-in templating capabilities and is mainly used for data manipulation and transformation.

  3. Data Binding: Handlebars.js provides data binding functionality, where changes in the data are automatically reflected in the rendered views. This enables developers to create reactive interfaces without manually updating the DOM. Underscore, however, does not have built-in data binding capabilities, requiring developers to handle data updates manually.

  4. Compatibility: Handlebars.js can be used in both client-side and server-side environments, making it versatile for various development scenarios. It can be integrated with frameworks like Ember.js for enhanced functionality. Meanwhile, Underscore is primarily designed for client-side JavaScript and is commonly used as a utility library in conjunction with other frameworks or libraries.

  5. Dependencies: Handlebars.js has no external dependencies and can be used as a standalone library. It has its own template engine and does not rely on other external JavaScript libraries. On the other hand, Underscore has no dependencies on other libraries either and can be used independently.

  6. Size: Handlebars.js is relatively larger in size compared to Underscore. The minified version of Handlebars.js is around 16 KB, while Underscore's minified version is only about 5 KB. This size difference can be a factor when considering page load times and network bandwidth.

In summary, Handlebars.js specializes in templating and data binding, offering an intuitive syntax for rendering dynamic content, while Underscore focuses more on data manipulation and functional programming. Both libraries have their own strengths and use cases, depend on the specific requirements of the project.

Share your Stack

Help developers discover the tools you use. Get visibility for your team's tech choices and contribute to the community's knowledge.

View Docs
CLI (Node.js)
or
Manual

Advice on Handlebars.js, Underscore

Asad
Asad

Software Engineer at Lisec Automation

Jun 15, 2020

Needs adviceon.NET.NETHandlebars.jsHandlebars.js

@All: I am searching for the best template engine for .NET. I started looking into several template engines, including the Dotliquid, Handlebars.js, Scriban, and Razorlight. I found handlebar a bit difficult to use when using the loops and condition because you need to register for helper first. DotLiquid and Scriban were easy to use and in Razorlight I did not find the example for loops.

Can you please suggest which template engine is best suited for the use of conditional/list and looping and why? Or if anybody could provide me a resource or link where I can compare which is best?

Thanks In Advance

240k views240k
Comments
Abigail
Abigail

Dec 6, 2019

Decided

Fast Healthcare Interoperability Resources (FHIR) provides standard data objects in JSON format for the healthcare industry. Since JSON objects are hierarchical and tree-like, we had a need to defensively 'pluck' fields from our JSON objects and do lots of mapping. We tried jQuery and Underscore and a few other technologies like FHIRPath; but Lodash has been the most well supported, works in the most contexts, has the cleanest syntax, etc. We particularly like the ES6 version of Lodash, where we can import the method names directly, without resorting to * or _ syntax. We got hooked on the 'get' function to defensively pluck fields from objects without crashing our user interface, and have found countless uses for the other lodash functions throughout our apps. Lodash is great for developing and optimizing algorithms.

38.3k views38.3k
Comments

Detailed Comparison

Handlebars.js
Handlebars.js
Underscore
Underscore

Handlebars.js is an extension to the Mustache templating language created by Chris Wanstrath. Handlebars.js and Mustache are both logicless templating languages that keep the view and the code separated like we all know they should be.

A JavaScript library that provides a whole mess of useful functional programming helpers without extending any built-in objects.

Statistics
GitHub Stars
-
GitHub Stars
27.4K
GitHub Forks
-
GitHub Forks
5.5K
Stacks
8.3K
Stacks
1.9K
Followers
3.2K
Followers
589
Votes
308
Votes
290
Pros & Cons
Pros
  • 106
    Simple
  • 76
    Great templating language
  • 50
    Open source
  • 36
    Logicless
  • 20
    Integrates well into any codebase
Pros
  • 85
    Utility
  • 55
    Simple
  • 40
    Functional programming
  • 32
    Fast
  • 28
    Open source
Integrations
Mustache
Mustache
No integrations available

What are some alternatives to Handlebars.js, Underscore?

TypeScript

TypeScript

TypeScript is a language for application-scale JavaScript development. It's a typed superset of JavaScript that compiles to plain JavaScript.

Pug

Pug

This project was formerly known as "Jade." Pug is a high performance template engine heavily influenced by Haml and implemented with JavaScript for Node.js and browsers.

Deno

Deno

It is a secure runtime for JavaScript and TypeScript built with V8, Rust, and Tokio.

Mustache

Mustache

Mustache is a logic-less template syntax. It can be used for HTML, config files, source code - anything. It works by expanding tags in a template using values provided in a hash or object. We call it "logic-less" because there are no if statements, else clauses, or for loops. Instead there are only tags. Some tags are replaced with a value, some nothing, and others a series of values.

Slim Lang

Slim Lang

Slim is a template language whose goal is to reduce the view syntax to the essential parts without becoming cryptic. It started as an exercise to see how much could be removed from a standard html template (<, >, closing tags, etc...). As more people took an interest in Slim, the functionality grew and so did the flexibility of the syntax.

Chart.js

Chart.js

Visualize your data in 6 different ways. Each of them animated, with a load of customisation options and interactivity extensions.

RactiveJS

RactiveJS

Ractive was originally created at theguardian.com to produce news applications. Ractive takes your Mustache templates and transforms them into a lightweight representation of the DOM – then when your data changes, it intelligently updates the real DOM.

EJS

EJS

It is a simple templating language that lets you generate HTML markup with plain JavaScript. No religiousness about how to organize things. No reinvention of iteration and control-flow. It's just plain JavaScript.

Immutable.js

Immutable.js

Immutable provides Persistent Immutable List, Stack, Map, OrderedMap, Set, OrderedSet and Record. They are highly efficient on modern JavaScript VMs by using structural sharing via hash maps tries and vector tries as popularized by Clojure and Scala, minimizing the need to copy or cache data.

Jinja

Jinja

It is a full featured template engine for Python. It has full unicode support, an optional integrated sandboxed execution environment, widely used and BSD licensed.

Related Comparisons

Bootstrap
Materialize

Bootstrap vs Materialize

Laravel
Django

Django vs Laravel vs Node.js

Bootstrap
Foundation

Bootstrap vs Foundation vs Material UI

Node.js
Spring Boot

Node.js vs Spring-Boot

Liquibase
Flyway

Flyway vs Liquibase