Benefits of the Django Contactless Template

I was wondering about this recently, what is the purpose of the Django spaceless template tag?

Obviously, it removes spaces from HTML tags, but does it also increase page loading speed?

I want to ask if removing spaces from html files helps?

+6
source share
2 answers

A new line / space is a character, yes, and it will increase the file size, especially with large loops and people-optimized template files (for example, a large FK list).

It is also very easy and safe to throw {% spaceless%} into the base template.

It also allows you to save the template code indented for readability, but usually without spaces for rendering HTML (I think commas are a common scenario).

+3
source

it would be wise to have a version of {% spaceless%} that crosses borders (ala Ifs and Fors), bad sadly, Django does not support this simple function. I have a dynamic class that is being added by me, and there are dozens of lines in spaces (all spaces match the pattern). This should not be too complicated for Django developers. adding indifferent to everyone if it were stupid.

If they are really worried, you may also have a depth parameter.

+2
source

All Articles