This is a migrated thread and some comments may be shown as answers.

SPA/MVVM: Adding templates using Require.js !text

1 Answer 78 Views
SPA
This is a migrated thread and some comments may be shown as answers.
Matthew
Top achievements
Rank 1
Matthew asked on 07 Dec 2014, 06:50 PM
Hey everyone,


I'm migrating from KO.js where knockout is able to parse the DOM when you add the view model to the element. However, I love how Kendo MVVM uses templates using script tags, almost in a backbone fashion. I was  watching the tech chat from July 24, 2013 on YouTube and they mentioned using the !text plugin from Require.js to load the script tags to the DOM. My question is, is this a good practice and what are the performance gains of adding the templates after the DOM loads compared to downloading them on the initial request? I realize that this may be more of a Require question, but I'm hoping that you can help in identifying the best practices. The application I'm working on now has about 200 templates. I'm showing a landing page while kendo and my other libs download, and some initial ajax calls are processed using nested require calls. My concern is that by loading the templates after the DOM loads adds an additional layer of complexity and could potentially cause the app to fail to load. Is the extra added error handling worth any possible performance gains? Maybe this is an old school concern, but as a trained network engineer, I would rather make the least amount of calls as possible.

Any help is greatly appreciated.

--Matt B

1 Answer, 1 is accepted

Sort by
0
Petyo
Telerik team
answered on 08 Dec 2014, 01:12 PM
Hello Matthew,

using separate requests speeds up the boot time (less things to download), but decrease the app "responsiveness", as each navigation may result in an additional request to fetch the UI. Both approaches make sense in certain cases. A thing you may try is to compile the resources with r.js and see how the app behaves when everything is loaded upfront. 

Regards,
Petyo
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
SPA
Asked by
Matthew
Top achievements
Rank 1
Answers by
Petyo
Telerik team
Share this question
or