Slaven Tomac Slaven Tomac - 1 year ago 121
Javascript Question

RequireJS text plugin - minification of templates

I'm using text plugin to import my templates. Now, in production I don't want that there are many XHR requests for templates so I would like to get them in one go.
My idea was to have build task which would take template and create something like:

define("my-template.tpl", function() {
return '<div>my content</div>'

and I was able to do this and define statement has been run, but requirejs still does XHR request when I have

define("my function", ["my-template.tpl"], function() {
<body of function here>

Did someone do any minification of text! plugin templates? Am I doing something wrong here?

Answer Source

RequireJS always requests all your modules asynchronously.

If you want one single call, you can build your app using the optimizer. You do not need this template wrapper (as you noticed by yourself, it won't change anything). The files required using the text plugin will be included in the built file too.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download