{"id":16860497,"url":"https://github.com/webpro/precompiled-templates","last_synced_at":"2025-04-11T08:34:10.646Z","repository":{"id":66134219,"uuid":"10450946","full_name":"webpro/precompiled-templates","owner":"webpro","description":"Performance, footprint and configuration of template engines and precompiled templates","archived":false,"fork":false,"pushed_at":"2013-06-18T16:55:52.000Z","size":128,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T06:05:32.993Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/webpro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-06-03T09:06:27.000Z","updated_at":"2025-02-28T03:02:23.000Z","dependencies_parsed_at":"2023-02-19T23:00:46.029Z","dependency_job_id":null,"html_url":"https://github.com/webpro/precompiled-templates","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpro%2Fprecompiled-templates","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpro%2Fprecompiled-templates/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpro%2Fprecompiled-templates/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpro%2Fprecompiled-templates/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webpro","download_url":"https://codeload.github.com/webpro/precompiled-templates/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248361680,"owners_count":21090964,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T14:24:56.856Z","updated_at":"2025-04-11T08:34:10.620Z","avatar_url":"https://github.com/webpro.png","language":"JavaScript","readme":"# Precompiled Templates\n\nDemo project around precompiled templates for some template engines. The goal is implement and configure things correctly, and to look for minimal footprint and best performance.\n\n* Module format: AMD (using Require.js + optimizer)\n* Modules are optimized and external templates will be precompiled and bundled.\n* The three optimized modules use the runtime version of each template engine.\n* Template engines included are [Handlebars](http://handlebarsjs.com/), [Hogan](http://twitter.github.io/hogan.js/), and [Dust](http://linkedin.github.io/dustjs/).\n* Dedicated plugins for require.js + optimizer are used for each engine ([HB](https://github.com/webpro/requirejs-handlebars), [HGN](https://github.com/webpro/requirejs-hogan), [DST](https://github.com/webpro/requirejs-dust)).\n* These plugins are stubbed out in the optimized modules.\n\n## Install \u0026 build\n\n    npm install\n    bower install\n    grunt\n\nWorking demo at `modules/index.html`. Open browser console for rendered output.\n\nAfter running `grunt`, the optimized build is at `dist/index.html`. \n\n## Numbers\n\n### Size of engine: full vs. runtime\n\nSwitching to the runtime version for precompiled templates can save lots of bytes:\n\n_ | Handlebars | Hogan | Dust\n---|---:|--:|--:\nFull library (min) | 37764 | 5885 | 32671\nRuntime (min) | 4416 | 2449 | 7291\nRuntime (min+gzip) | 1876 | 1117 | 2343\n\n**NOTE** Don't compare apples and oranges: this table is only meant to show the difference between the full and runtime version of a particular engine.\n\n### Size of compiled templates\n\nWhen precompiling templates from source to a JavaScript function, the size increases (this is normal: e.g. templating syntax is translated to function calls). With a small source template of 220 bytes:\n\n_ | Handlebars | Hogan | Dust\n---|--:|--:|--:|\nSource | 220 | 220 | 202\nCompiled JS | 1061 | 683 | 671\n\nWith a larger source template of 27254 bytes:\n\n_ | Handlebars | Hogan | Dust\n---|--:|--:|--:|\nSource | 27254 | 27254 | 26820\nCompiled JS | 45689 | 39274 | 33657\nIncrease | 68% | 44% | 25%\n\nNote that the Dust source templates are slightly smaller due to its delimiter syntax (`{{..}}` vs. `{..}`).\n\n### Performance\n\nPerformance measurements are done using jsPerf: for the [small source template](http://jsperf.com/precompiled-templates-hb-hgn) and the [larger](http://jsperf.com/precompiled-templates-large) one. These charts indicate that Handlebars is the fastest to render precompiled templates.\n\n## Conclusions\n\n* **Footprint**: Hogan has the smallest footprint, both the engine itself and the precompiled templates are small (it also has the smallest feature set!). However, Dust quickly catches up when templates become larger.\n* **Performance**: Handlebars seems the fastest engine to render precompiled templates in most cases/browsers (though the tests are very limited in range and scale!).\n\nIt's important to note that this is a very rough comparison between template engines using only their most basic features. When adding some complexity (e.g. helpers, partials), size and performance will change.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebpro%2Fprecompiled-templates","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebpro%2Fprecompiled-templates","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebpro%2Fprecompiled-templates/lists"}