AngularJS' directives are awesome but since each of them makes a request, I'm wondering if it'd be better to minimize the use of it?
Let's imagine I have something like that:
<hero></hero>
<slideshow></slideshow>
<section>
<sidebar></sidebar>
<blog-articles></blog-articles>
<rss-feed></rss-feed>
<socials></socials>
</section>
In this example I'm making 6 differents requests. Isn't it slowing down the whole application? And what if my controllers are also dyanmically loaded, adding 6+ more files?
To make it clearer, below is how I define those directives.
angular.module( 'module', [] )
.directive( 'hero', function () {
return {
restrict: 'E',
templateUrl: 'hero.html'
};
} )
.directive( 'slideshow', function () {
return {
restrict: 'E',
templateUrl: 'slideshow.html'
};
} )
.directive( 'sidebar', function () {
return {
restrict: 'E',
templateUrl: 'sidebar.html'
};
} )
.directive( 'blogArticles', function () {
return {
restrict: 'E',
templateUrl: 'blog-articles.html'
};
} )
.directive( 'rssFeed', function () {
return {
restrict: 'E',
templateUrl: 'rss-feed.html'
};
} )
.directive( 'socials', function () {
return {
restrict: 'E',
templateUrl: 'socials.html'
};
} );
Given this example each directives makes an ajax call to load the proper html file. Maybe there's a way to minimize the calls?