Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Framework: Remove usages of lodash trimEnd() #48255

Merged
merged 1 commit into from Dec 14, 2020
Merged

Conversation

tyxla
Copy link
Member

@tyxla tyxla commented Dec 11, 2020

We have only a couple usages of lodash's trimEnd() method. They can be refactored to use native methods. This PR removes them, in order to make us a bit less dependent on lodash.

This PR should not offer any visual or functional changes.

Changes proposed in this Pull Request

  • Framework: Remove usages of lodash trimEnd() and some trim() usages alongside that.

Testing instructions

  • Go to /domains/manage/:domain/redirect-settings/:site where :domain and :site correspond to a WP.com site that has a site redirect enabled.
  • Change the redirect to something else.
  • Verify after the successful save, the domain part of the URL gets replaced with the new site redirect domain value.
  • Go to /settings/security/:site where :site is a Jetpack site with a paid plan.
  • Open the Prevent brute force login attacks card.
  • Verify that if the IP address is in the allowed list, the button to add it there is disabled; and if it's not there, the button is enabled.
  • Verify that the button works as expected and appends the current IP to the list.
  • ETK: Verify changes make sense (replacement is pretty straightforward).

@tyxla tyxla added [Type] Enhancement Framework [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. [Type] Janitorial labels Dec 11, 2020
@tyxla tyxla requested review from sgomes and a team December 11, 2020 12:55
@tyxla tyxla self-assigned this Dec 11, 2020
@matticbot
Copy link
Contributor

@matticbot
Copy link
Contributor

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

Sections (~637 bytes removed 📉 [gzipped])

name               parsed_size           gzip_size
settings-security      -1507 B  (-0.4%)     -275 B  (-0.3%)
domains                 -782 B  (-0.1%)      -82 B  (-0.0%)
zoninator               -196 B  (-0.1%)      -20 B  (-0.0%)
woocommerce             -196 B  (-0.0%)      -30 B  (-0.0%)
site-blocks             -196 B  (-0.1%)      -21 B  (-0.0%)
settings                -196 B  (-0.0%)      -29 B  (-0.0%)
reader                  -196 B  (-0.0%)      -29 B  (-0.0%)
posts-custom            -196 B  (-0.0%)      -30 B  (-0.0%)
posts                   -196 B  (-0.0%)      -30 B  (-0.0%)
plans                   -196 B  (-0.0%)      -29 B  (-0.0%)
people                  -196 B  (-0.1%)      -29 B  (-0.0%)
import                  -196 B  (-0.1%)      -33 B  (-0.0%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Async-loaded Components (~210 bytes removed 📉 [gzipped])

name                                                     parsed_size           gzip_size
async-load-signup-steps-import-url-onboarding                 -196 B  (-0.5%)      -33 B  (-0.3%)
async-load-signup-steps-import-url                            -196 B  (-0.8%)      -34 B  (-0.5%)
async-load-design-blocks                                      -196 B  (-0.0%)      -30 B  (-0.0%)
async-load-design                                             -196 B  (-0.0%)      -30 B  (-0.0%)
async-load-calypso-layout-nps-survey-notice                   -196 B  (-0.7%)      -26 B  (-0.4%)
async-load-calypso-components-web-preview-component           -196 B  (-0.0%)      -25 B  (-0.0%)
async-load-calypso-blocks-support-article-dialog-dialog       -196 B  (-0.2%)      -32 B  (-0.1%)

React components that are loaded lazily, when a certain part of UI is displayed for the first time.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@matticbot
Copy link
Contributor

Caution: This PR affects files in the Editing Toolkit Plugin on WordPress.com
Please ensure your changes work on WordPress.com before merging.

D54173-code has been created so you can easily test it on your sandbox. See this FieldGuide page about developing the Editing Toolkit Plugin for more info: PCYsg-ly5-p2

@tyxla tyxla requested a review from a team December 11, 2020 13:06
Copy link
Contributor

@sgomes sgomes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, good work @tyxla! 👍

I didn't test the changes in Calypso, as I can't easily reproduce the test conditions, but I did manually test the changes and verified that the behaviour matches the Lodash code it replaces.

@tyxla
Copy link
Member Author

tyxla commented Dec 14, 2020

Thanks for the review, @sgomes 🙌

@tyxla tyxla merged commit 2bfb726 into trunk Dec 14, 2020
@tyxla tyxla deleted the remove/lodash-trim-end branch December 14, 2020 11:42
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Dec 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants