Archive for the ‘mp-wp’ Category

The MP-WP Weightloss Program: Removing JavaScript

Monday, June 15th, 2020

This is the second major slimming patch for mp-wp1 and the result is a streamlined mp-wp roughly half the size of the original genesis, all without removing anything that actual people actually use. The following are the stats for this patch:

Before After Reduction
Lines of Code 138,088 89,186 35.4%
Bytes on Disk 4,923,363 3,060,6652 37.8%

Since this was more than a simple find ./mp-wp/ -iname "*.js" | xargs rm, it's worth outlining what exactly was removed/changed in this patch:

  • ALL JS and JS related code has been removed, including inline JS, PHP used to load JS, as well as code related to popups and other elements generated by JS.
  • The JS widget to edit categories inline while editing a post has been removed. You can select existing categories for your post but to manage them (add/delete) you must navigate to the category page. Tags can be specified as a comma-delimited list and new tags will be created on save.
  • JS warning alerts have been removed (e.g. "are you sure you want to delete this?), to mitigate against accidental deletion, in-row delete links for Posts have been removed.3
  • Inline editing ("quick edit") and bulk editing has been removed from tables, as this relied on JS. Bulk edit can be achieved directly via MySQL.
  • The notion of media "attached" to an article is gone, as this relied on the JS popup modal for selecting and attaching media. Based on the survey it also seemed like no one really used this feature, instead relying on their own scripts for generating the HTML code to insert images into articles. Removing the media upload interface entirely was discussed, but in order to support the multi-author use case it was decided to keep this around for now.
  • Interfaces for modifying themes and plugins have been removed. Similarly interfaces for adding/deleting plugins has been removed. All of these features still work the same way you're probably used to using them already, by modifying files on the filesystem directly.
  • Any function in wp-includes/deprecated.php that wasn't called anywhere has been removed. In a future patch the rest of these could probably be removed.
  • The no-op wptexturize() function (defined in wp-includes/formatting.php and all calls to it have been removed.
  • The Adobe Flash file uploader has been removed.
  • Theme "functions" have been removed, except for registering sidebar widgets. I would've liked to have removed that as well but simply couldn't muster the will to do it in this patch.

In addition to the above I also decided to clean up the admin UI a bit and give it, what I thought to be, a much needed facelift:

  • The wp-admin/images/ directory has been removed. This contained base64 encoded PNGs, saved as SVGs, for use as icons in the admin interface. Along with this, the entire admin interface has been given a minor but comprehensive facelift4.
  • All "widgets" have been removed from the Dashboard except for the overview, recent drafts, and recent comments widgets.
  • Bulk action rows below tables have all been removed. They just weren't necessary since long pages are paginated anyway.
  • The wp-admin.css file was moved from wp-admin/ to wp-admin/css/, where all the other admin CSS lives.
  • All "rtl" CSS has been removed.

This site has been running on this patch for the last 24 hours, and I've been banging on it locally for the last month or so. However, as always, you should backup your db and site directory before deploying this or any other major changes to mp-wp. If you have a custom theme, it should work fine as is with these changes. Likewise, if you're using any plugins not included in the trunk of mp-wp, they should work as well.

Feedback/additional testing is welcome and appreciated. This is a big change so I want to make sure everything works as expected for all current mp-wp users.

Patch and Signature



  1. After the first, which removed TinyMCE. []
  2. of these remaining bytes, about 220k are dedicated to empty directories not removed by V. []
  3. Should they be removed in all tables? In some cases this means adding "Delete" buttons to single-item views where they previously were only present in the list view rows, e.g. in the Media Library. []
  4. The ability to select a color scheme for the admin UI, and all associated code, has also been removed. []