Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8825585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:54:53+00:00 2026-06-14T06:54:53+00:00

After reading What are the differences between Mustache.js and Handlebars.js? I was puzzled with

  • 0

After reading What are the differences between Mustache.js and Handlebars.js? I was puzzled with a question:

What does pre-compiling of javascript templates means?

Previously I was using a simple client-side caching, which was working something like this:

var tmpCache = {};
if (tmpIneed is in tmpCache){
  use it
} else {
  take it from DOM / upload from external file
  put save it in tmpCache
  use it
}

How is this fundamentally different from my technique?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:54:55+00:00Added an answer on June 14, 2026 at 6:54 am

    Since Handlebars.js can have different expression/rendering logic in the template, these expressions are typically processed during runtime. For better performance and smaller dependency, the templates can be pre-compiled before deployment. For example, here is a simple handlebar template:

    <div class="entry">
      <h1>{{title}}</h1>
      <div class="body">
        {{body}}
      </div>
    </div>
    

    And here is the pre-compiled output

    (function() {
    var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
    templates['test.handlebar'] = template(function (Handlebars,depth0,helpers,partials,data) {
    helpers = helpers || Handlebars.helpers;
    var buffer = "", stack1, foundHelper, functionType="function",   escapeExpression=this.escapeExpression;
    
    
    buffer += "<div class=\"entry\">\r\n  <h1>";
    foundHelper = helpers.title;
    if (foundHelper) { stack1 = foundHelper.call(depth0, {hash:{}}); }
    else { stack1 = depth0.title; stack1 = typeof stack1 === functionType ? stack1() : stack1; }
    buffer += escapeExpression(stack1) + "</h1>\r\n <div class=\"body\">\r\n    ";
    foundHelper = helpers.body;
    if (foundHelper) { stack1 = foundHelper.call(depth0, {hash:{}}); }
    else { stack1 = depth0.body; stack1 = typeof stack1 === functionType ? stack1() : stack1; }
    buffer += escapeExpression(stack1) + "\r\n  </div>\r\n</div>";
    return buffer;});
    })();
    

    More info about pre-compiling can be found here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After reading about the differences between appSettings and applicationSettings in a web.config file, I'd
After reading both : difference between "void 0 " and "undefined" , https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Operators/void I
After reading a lot about the differences between REST and SOAP, I got the
After reading a question on the difference between pointers and references , I decided
I am wondering what the difference is between release and dealloc? After reading, the
After reading monkeytalk faq from http://www.gorillalogic.com/testing-tools/monkeytalk/documentation/monkeytalk-faq : How does it all work? MonkeyTalk is
After reading answer to this question: Make "make" default to "make -j 8" I
After reading this question, I need to clear up some things. IQueryable<Customer> custs =
After reading some excellent posts about the difference between AppDomain.UnhandledException and Application.DispatcherUnhandledException, it appears
After reading already asked question on the subject and a lot of googling I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.