#31524: Stop minifying only some admin static assets
------------------------------------------------+------------------------
               Reporter:  Jon Dufresne          |          Owner:  nobody
                   Type:  Cleanup/optimization  |         Status:  new
              Component:  contrib.admin         |        Version:  master
               Severity:  Normal                |       Keywords:
           Triage Stage:  Unreviewed            |      Has patch:  0
    Needs documentation:  0                     |    Needs tests:  0
Patch needs improvement:  0                     |  Easy pickings:  0
                  UI/UX:  0                     |
------------------------------------------------+------------------------
 Here is a list of JavaScript files in the admin app and their size:

 {{{
   20K django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js
   15K django/contrib/admin/static/admin/js/inlines.js
   13K django/contrib/admin/static/admin/js/SelectFilter2.js
  8.8K django/contrib/admin/static/admin/js/urlify.js
  7.6K django/contrib/admin/static/admin/js/calendar.js
  6.7K django/contrib/admin/static/admin/js/actions.js
  5.9K django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js
  5.4K django/contrib/admin/static/admin/js/core.js
  5.3K django/contrib/admin/static/admin/js/SelectBox.js
  5.2K django/contrib/admin/static/admin/js/inlines.min.js
  3.2K django/contrib/admin/static/admin/js/actions.min.js
  1.9K django/contrib/admin/static/admin/js/collapse.js
  1.5K django/contrib/admin/static/admin/js/prepopulate.js
  1.1K django/contrib/admin/static/admin/js/autocomplete.js
   911 django/contrib/admin/static/admin/js/collapse.min.js
   878 django/contrib/admin/static/admin/js/cancel.js
   674 django/contrib/admin/static/admin/js/change_form.js
   569 django/contrib/admin/static/admin/js/popup_response.js
   495 django/contrib/admin/static/admin/js/prepopulate_init.js
   379 django/contrib/admin/static/admin/js/prepopulate.min.js
   363 django/contrib/admin/static/admin/js/jquery.init.js
 }}}

 Some things to notice:

 1. Only 4 out of 17 files are minified.
 2. The largest file, DateTimeShortcuts.js, is only 20 KB.
 3. The largest file is also not included in the list of minified files.
 4. All uncompressed files are smaller than the size of the 3 font assets,
 each ~80 KB.
 5. All uncompressed files are smaller than the minified jQuery, ~87 KB.

 I'm not sure if there is a deliberate or historical reason that only a
 fraction of the static assets are minified, but it looks like it could be
 an oversight. The approach is inconsistent.

 Minifying is step a contributor must manually do. The documentation for
 doing so is here:

 https://docs.djangoproject.com/en/dev/internals/contributing/writing-
 code/javascript/#javascript-patches

 This is a step that is easy to forget, myself included. Whether or not one
 remembers to compress static assets will also affect the outcome of tests.

 I suggest we drop the minificaiton of admin files altogether. For such
 small files, it doesn't seem worth it to add a build step and
 inconsistently at that.

 In a typical production scenarios, the static assets will be cached and
 possibly compressed. Compressing static assets largely removes the size
 gains of minification. Additionally, there are third party apps to fill
 the role of static asset optimization.

 I think we should continue to distribute the vendored libraries minified,
 however as they are not manually handled during typical contributions.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31524>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/052.ea2300ee85e18d81264a88fcdefe1a34%40djangoproject.com.

Reply via email to