[Django] #30229: inlines.min.js contains an unnecessary polyfill

1 view
Skip to first unread message

Django

unread,
Mar 1, 2019, 8:06:02 AM3/1/19
to django-...@googlegroups.com
#30229: inlines.min.js contains an unnecessary polyfill
------------------------------------------------+------------------------
Reporter: djw | 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 |
------------------------------------------------+------------------------
Due to the use of `.find()` in this code, the Closure Compiler is adding a
polyfill. However, `find` is only being called on jQuery objects, so this
is unnecessary, and adds around 1kb to the minified file.

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

Django

unread,
Mar 1, 2019, 8:12:34 AM3/1/19
to django-...@googlegroups.com
#30229: inlines.min.js contains an unnecessary polyfill
-------------------------------------+-------------------------------------
Reporter: djw | 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 djw):

* has_patch: 0 => 1


Comment:

I've created a patch here: https://github.com/django/django/pull/11040

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

Django

unread,
Mar 1, 2019, 12:33:02 PM3/1/19
to django-...@googlegroups.com
#30229: inlines.min.js contains an unnecessary polyfill
-------------------------------------+-------------------------------------
Reporter: djw | 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 Tim Graham):

* stage: Unreviewed => Ready for checkin


Comment:

Dan's explanation of why adding `rewrite_polyfills=false` to `compress.py`
is okay:

The parameter's badly-named, but it controls whether polyfills are added
to the code when the compiler detects that ES6+ features are being used.

In this case, it thinks Array.prototype.find is being used, which is an
ES2015 feature, and isn't available in all browsers. The polyfill code
will add an implementation for browsers which don't have a native
implementation.

Django's inlines.js only uses jQuery's .find() method, so this polyfill is
unnecessary.

It's possible that in future we'd want to rewrite Django's JavaScript code
using more modern syntax, which might require the use of polyfills.
However, I in that case I think it would be preferable to add those
libraries explicitly, rather than have them added during minification.

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

Django

unread,
Mar 1, 2019, 1:01:17 PM3/1/19
to django-...@googlegroups.com
#30229: inlines.min.js contains an unnecessary polyfill
-------------------------------------+-------------------------------------
Reporter: djw | 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 Tim Graham <timograham@…>):

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


Comment:

In [changeset:"fe65918dca405644047b7dbc295d14535626a83a" fe65918]:
{{{
#!CommitTicketReference repository=""
revision="fe65918dca405644047b7dbc295d14535626a83a"
Fixed #30229 -- Removed polyfill from inlines.min.js.

find() is only called on jQuery objects, so the polyfill is necessary.
}}}

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

Reply all
Reply to author
Forward
0 new messages