Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handlebar pre compiled is still slow #1215

Closed
fcpauldiaz opened this issue Apr 24, 2016 · 4 comments
Closed

Handlebar pre compiled is still slow #1215

fcpauldiaz opened this issue Apr 24, 2016 · 4 comments

Comments

@fcpauldiaz
Copy link

fcpauldiaz commented Apr 24, 2016

I'm using phonegap with handlebars but even if I precompiled the templates is still slow.
Maybe putting a script inside a template is causing this.

<table class="table table-striped table-hover">
    <thead>
        <tr>
            <th>IMG</th>
        </tr>
    </thead>
    <tbody>
        {{#each array}}
        <tr>
            <td> 
                <a  href= "{{this}}" class="swipebox" title="My Caption">
                <img src= "{{this}}" alt="image"  width="50" height="50">
                </a>
            </td>
        </tr>
        {{/each}}
    </tbody>
</table>
<script>    
    var table = $('table').dataTable({
        lengthMenu: [[-1, 50, 25, 10], ["Todo", 50, 25, 10]],
        sPaginationType: "full_numbers",
        language: {
        "url": "json/Spanish.json"
        }
    });

</scr{{undefined}}ipt>
@stevenvachon
Copy link

stevenvachon commented Apr 24, 2016

Your HTML is atrocious. The reason for the slowdown cannot be addressed without your view model.

@fcpauldiaz
Copy link
Author

fcpauldiaz commented Apr 24, 2016

This is the context

  <script type="text/javascript">
        var array = [];

        for (i = 0; i < 3; i++) {
          var src = "img/arrow_ + i + .png";

          array.push(src);

        }
        var context = {"array":array}
        var theCompiledHtml =   Handlebars.templates['events.tmpl'](context);
        $('.render').html(theCompiledHtml);   

    </script>

@methodbox
Copy link

methodbox commented May 15, 2016

var theCompiledHtml = Handlebars.templates['events.tmpl'](context);

I'm not sure what your function in the script tags are for; appears to be for iterating over an array of images, but the code I pasted in for calling your precompiled template doesn't belong there.

Ideally, you'd have a single app file with your template calls, telling the page where to output the rendered HTML.

Right now, I think what I'm seeing will result in your precompiled template being fully evaluated by the browser, before rendering. This makes precompiling worthless.

@nknapp
Copy link
Collaborator

nknapp commented Apr 5, 2020

Closing due to inactivity.

@nknapp nknapp closed this as completed Apr 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants