I'm going back and forth between loading all my template scripts on the main page load or dynamically loading them as I need them. A little background. This is using kendo mvvm in a .net mvc application. This is a large old application so the question isn't regarding what tech stack to use. I'm stuck with using what I have.
IE - the templates are stored in partials (.cshtml) files.
Definition of a template
<script id="myTemplate" type="text/x-kendo-tmpl">
<div> some text </div>
</script>
Added to the page with razor syntax
@Html.Partial("myTemplateParial")
So lets say I have 8 templates. The templates can get a decent size. If I just load them all on the main page. Say index.cshtml. Since they are just script templates it's not like they are rendered or anything. Though all these will be in the markup thus increasing the size of the page. Though performance shouldn't be hit.
The other option is to load dynamically via ajax and return the partial which is just the script template. The downside of this is making multiple ajax calls vs loading initially and only using ajax calls to grab data for the view models.
Does anyone have any insight on why to go one way versus the other?