django-htmlmin
django-htmlmin copied to clipboard
Minify inline JavaScript
It'd be nice to minify inline JavaScript.
The minify
function could receive a boolean parameter (just like ignore_comments
):
minify(html_code, compress_js =True)
minify(html_code, compress_js=False)
Hi @fsouza , can we minimize javascript in this now......
Hi @paritosh90, i think that it is ideal to use tools like django-compressor, that minifies and group JavaScript files.
So, the code below:
{% compress js %}
<script src="myfile.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
alert("bla bla");
});
</script>
{% endcompress %}
would generate one javascript file with the contents compressed, and change the entire compress
block to a <script src="file.js"></script>
tag.
@fsouza you are right about django-compress but here we are assigning name to some javascript variables in django template like /////////////////////////////////////////////////////
//////////////////////////////////////////////////// here we cannot use django-compress, because it combine all js into one when server restarts. I think if we implement this feature in django-htmlmini this will be the best app to be used for minifying client side code and its combination with django-compress will do all of the job one needs for minifying in django. Anyways this app is quite cool
Thanks
This makes sense. Thank you @paritosh90.
I'd like to be able to minify the Google Analytics <head>
scripts inline without passing them off to Compressor with the other JavaScript files. I specifically don't want these in the output file generated by Compressor, nor in an external file at all.