3

I am serving CSS and javascripts in my django website, so how to obfuscate and minimize them. 1 solution is: To serve already obfuscated and minimized js and css.

can I have a flag set in settings.py that to switch on and off the obfuscation?

So, that I can develop on normal human readable code and serve the obfuscated css and js.

What is the standard method of achieving this?

10
  • 1
    I just want to obfuscate or minimize [Either one that makes it un-readable] the js and css. Commented Oct 13, 2011 at 16:57
  • 1
    Please feel free.. to ask what you want. Down vote drives people away, hurt sharing.. Commented Oct 13, 2011 at 17:02
  • 3
    obfuscating your code hurts sharing Commented Oct 13, 2011 at 17:25
  • 1
    @pastylegs I don't see the problem with obfuscating and then minimizing what you serve in production. If you want to share code put the uncompressed versions on github / somewhere with documentation and source control. Commented Oct 14, 2011 at 3:27
  • 1
    @Xeon06 When would obfuscating minified JS result in significantly bigger file sizes? Commented Oct 14, 2011 at 3:28

1 Answer 1

3

I would recommend django-compressor. It supports running your JS/CSS through a number of different compression algorithms (JSMin, Slim It, YUI, Closure Compiler).

Sign up to request clarification or add additional context in comments.

5 Comments

It seems good. So, any other option and what about the industry standards ? How does the industry does that ?
There are a number of popular compression algorithms so I don't think you can really call one standard.
I am using this, it working good for js. Any suggestions for CSS - I don't want to include executables like tidycss ?
YUI, CSSTidy and CSSMin are supported by django-compressor for compressing CSS. CSSMin is a python port of YUI CSS compression and wouldn't require configuring an executable.
django-compressor just works on css and js. But css obfuscation entails adapting templates (because class names are used across template) so we will not have meaningful CSS class names when inspecting in browser. The same goes for JS. Can we achive this goal with django-compressor or another library?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.