[Django] #31524: Stop minifying only some admin static assets

6 views
Skip to first unread message

Django

unread,
Apr 28, 2020, 11:31:07 PM4/28/20
to django-...@googlegroups.com
#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.

Django

unread,
Apr 28, 2020, 11:44:26 PM4/28/20
to django-...@googlegroups.com
#31524: Stop minifying only some admin static assets
-------------------------------------+-------------------------------------

Reporter: Jon Dufresne | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jon Dufresne):

* has_patch: 0 => 1


Comment:

https://github.com/django/django/pull/12821

--
Ticket URL: <https://code.djangoproject.com/ticket/31524#comment:1>

Django

unread,
Apr 29, 2020, 2:32:40 AM4/29/20
to django-...@googlegroups.com
#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 | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Carlton Gibson):

* stage: Unreviewed => Accepted


Comment:

Yes, I think this is reasonable. (It's been slowly bubbling up my nag list
for a while so... 👍)

--
Ticket URL: <https://code.djangoproject.com/ticket/31524#comment:2>

Django

unread,
Apr 29, 2020, 3:54:37 AM4/29/20
to django-...@googlegroups.com
#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 | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by Nick Pope):

There are additional problems that occur with minifying along with changes
rather than at release/build time:

- It is possible to forget to do it and missing changes are only noticed
in production, i.e. with `DEBUG = False`.
- Two competing pull requests could minify independently and the one
merged second could lose the changes of the first unless rebased and
minified correctly.

--
Ticket URL: <https://code.djangoproject.com/ticket/31524#comment:3>

Django

unread,
May 14, 2020, 9:40:26 AM5/14/20
to django-...@googlegroups.com
#31524: Stop minifying only some admin static assets
-------------------------------------+-------------------------------------

Reporter: Jon Dufresne | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/31524#comment:4>

Django

unread,
May 14, 2020, 10:08:14 AM5/14/20
to django-...@googlegroups.com
#31524: Stop minifying only some admin static assets
-------------------------------------+-------------------------------------

Reporter: Jon Dufresne | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: contrib.admin | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson <carlton@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"81ffedaacc0d907b9feb73783edefdffd0ced606" 81ffeda]:
{{{
#!CommitTicketReference repository=""
revision="81ffedaacc0d907b9feb73783edefdffd0ced606"
Fixed #31524 -- Removed minified static assets from the admin.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/31524#comment:5>

Django

unread,
May 14, 2020, 11:19:22 AM5/14/20
to django-...@googlegroups.com
#31524: Stop minifying only some admin static assets
-------------------------------------+-------------------------------------

Reporter: Jon Dufresne | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: contrib.admin | Version: master

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"9d211f149a8141a3990acae4cdada3875b9339b3" 9d211f1]:
{{{
#!CommitTicketReference repository=""
revision="9d211f149a8141a3990acae4cdada3875b9339b3"
Refs #31524 -- Moved release notes for
81ffedaacc0d907b9feb73783edefdffd0ced606 to 3.2.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/31524#comment:6>

Reply all
Reply to author
Forward
0 new messages