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 9076413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:06:11+00:00 2026-06-16T19:06:11+00:00

I have a backbone application, which is served by a symfony2 server. I have

  • 0

I have a backbone application, which is served by a symfony2 server.

I have many backbone views and each has several templates that are rendered at different times using underscore’s templating engine.

I am trying to figure out how to serve the underscore templates to the client with maximum efficiency.

Up until now I’ve written all of the templates in twig, and then rendered them as inline script tags to the response HTML during the initial request. This resulted in a long response time from the server during the first time a user enters my application.

output example:

<html>
<head>
   ...
</head>
<body>
    <script type="text/template" id="template1">
        <div class="example">
            <%= someparam %>
        </div>
    </script>
    <script type="text/template" id="template2">
        <div class="anotherExample">
            <%= otherparam %>
        </div>
    </script>
    ...
    ...
    ...
</body>
</html>

Alternatives

Now I’m looking for a better way to load these templates. perhaps by getting them in a second request in a single file, like an external JS file. But with anything I’ve tried, I have found it difficult to either access individual templates (like referencing them by id) or to keep them all in an efficient structure (in a single file, and without too much string manipulation or too many http requests).

TL;DR

How would one load many underscore templates?

  • 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-16T19:06:12+00:00Added an answer on June 16, 2026 at 7:06 pm

    You could consider the JST approach, which is to concatenate the templates into a single javascript file. The pattern is described in this Backbone Patterns tutorial.

    I’m not familiar with Symfony/Twig, so I don’t know if there is any tooling available. Based on your question I would guess it’s easy to use your existing tools to render the templates into a javascript file instead of the HTML document.

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

Sidebar

Related Questions

We're designing a backbone application, in which each server-side collection has the potential to
I have a very complex Backbone application with many views/Models and collections. at times
I have a Backbone.js application that allows users to create graphs based on large
In my Backbone application I have a main view that shows previews of posts.
I have JavaScript application, where I use client-side templates (underscore.js, Backbone.js). Data for initial
I have a top level application called SearchApp which has a sub-app called TeamApp
I have a Rails application with the backbone-rails gem. Which works out fine but
I have a pretty basic Backbone app which uses a router to instantiate views
I'm trying to have my backbone application check the server as often as possible
I'm working on a backbone rails application that needs to poll the server to

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.