jvc26
jvc26

Reputation: 6513

Handling browser conditional JS with JS compressors in Django

Essentially, a reasonably simple question. Like most websites which have to support old browsers, we have a bunch of conditional loading JS scripts:

<!--[if lte IE 8]><!--><script src="/static/js/toisostringshim.js"></script><!--<![endif]-->
<script src="/static/js/jquery-1.10.2.min.js"></script>
<script src="/static/js/jquery-ui-1.10.0.custom.min.js"></script>
<!--[if lte IE 8]><script src="/static/js/r2d3.min.js" charset="utf-8"></script><![endif]-->
<!--[if gte IE 9]><!--><script src="/static/js/d3.v3.min.js"></script><!--<![endif]-->
<script src="/static/js/etc.min.js"></script>

We have quite a number of JS dependencies, and our plan was to compress these using django-compressor to reduce query load, and to improve re-loading the dependencies when the Javascript changes (avoiding browser cache issues).

The question really is, if you have a cascade of loading which needs to happen in order (i.e. Jquery before JQ-UI etc. and some of the components are conditional (D3 vs r2d3), do you just compress as many as possible of the non-conditional ones in order, or is there a more intelligent way of doing this?

Upvotes: 1

Views: 148

Answers (1)

exit2
exit2

Reputation: 31

Have you considered using some sort of AMD? Like require.js?

Upvotes: 1

Related Questions