Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm pretty new in the AngularJs world and I'm trying to follow some good practices. In some pages of an app I'm programming, there are some scripts (jquery plugins I'm wrapping in directives) I'll be using in some pages. These same scripts won't be needed in site locations.

I'm wondering if it's ok to include these scripts right into the template:

<table id="grid">
    <tr>
        <th>Foo</th>
    </tr>
    <tr ng-repeat="lorem in lorems">
        <td>{{lorem.text}}</td>
    </tr>

</table>

<script src="assets/plugins/jQGrid/jQGrid.min.js"></script>

This way, the script would be included only when this specific directive is called. Off course, I can include it into the boostrap .html file, but the script would be allocated in memory even in those cases it's not needed.

I'm trying achieve some kind of lazy loading here.

Any ideas would be nice.

share|improve this question
    
It's not ok to include scripts into the template, if you want you can load scripts from controllers: loadScript('some script url', functionInControllerThatRequiresScipt()); and loadScript: stackoverflow.com/questions/950087/… –  christina Oct 22 '14 at 10:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.