python - Better way to deploy compressed assets - Django Compressor -


so have tricky problem not able find better solution for.

i using django-compressor great job in compressing/minifying files. problem facing during deployment. time, have been using compress tag on production , curl on pages make sure regenerates correct css/js. way, new users don't have feel brunt of compression process.

i know has management command can pre-compress files, can pushed cdn , perhaps preload them behind scenes on landing/login pages.

here problem, in of javascript code, using context vars , django tags [both custom , native].

var first = '{% some_tag some_context_var %}'; var name = '{{some_context_var}}'; 

this causes error since during compression tries execute tag doesn't have values. come compress_offline_context not dynamic.

did encounter issue before. how do compression if code mixed in django tags/context variables?

found way resolve this.

basically moved variables own script blocks outside of compressor , use variables inside compression code. e.g.

 <script type="text/javascript">     var some_var = '{% ctx_var %}';  </script>   {% compress js %}      //before do_something_function('{% ctx_var %}')       do_something_function(some_var);  

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -