Make WordPress Core

Opened 4 months ago

Last modified 5 weeks ago

#58996 new enhancement

Consider removing the "imagemin" task from Grunt

Reported by: azaozz's profile azaozz Owned by:
Milestone: 6.5 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: has-patch 2nd-opinion
Focuses: Cc:

Description

WordPress uses Imagemin in Grunt to minify new images. However it seems the last time new (non svg) images were added was 7 years ago. See:

https://core.trac.wordpress.org/browser/trunk/src/wp-includes/images?order=date&desc=1
https://core.trac.wordpress.org/browser/trunk/src/wp-admin/images?order=date&desc=1

Seems the imagemin task in Grunt has been redundant for a long time. Perhaps would be good to retire it and go back to minifying new images "by hand" before committing them, if non-svg images are ever added again.

Attachments (1)

58996.diff (426 bytes) - added by desrosj 4 months ago.

Download all attachments as: .zip

Change History (4)

@desrosj
4 months ago

#1 follow-up: @desrosj
4 months ago

  • Keywords has-patch 2nd-opinion added

I'm not sure that relying on "by hand" is the best path here. Even for experienced contributors and committers, it's very easy to forget steps like this when it's not often images are added.

It's true that within those two directories images have not been added, but there have been lots of images added to the wp-content/themes directory. I think it's probably worth looking at expanding the imagemin task to include themes.

I attached a patch that expands to theme directories, and running npm run grunt precommit:image results in 106 images being minified, and seems to save ~1KB per image within the theme.

The fact that the images within themes can be further minified is a good example of forgetting to manually perform minifying prior to committing.

#2 in reply to: ↑ 1 @SergeyBiryukov
4 months ago

Replying to desrosj:

It's true that within those two directories images have not been added, but there have been lots of images added to the wp-content/themes directory. I think it's probably worth looking at expanding the imagemin task to include themes.

I agree, it seems like the task would still be beneficial for themes.

#3 @jorbin
5 weeks ago

  • Milestone changed from 6.4 to 6.5

I agree with @desrosj that we should expand this rather than eliminate it.

However, I do think this might be better for 6.5 as we are now in RC. Feel free to move back to 6.4 if someone feels strongly otherwise.

Note: See TracTickets for help on using tickets.