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

feat: minify and notify clipable email body #764

Merged
merged 2 commits into from
Mar 22, 2022

Conversation

miguelpeixe
Copy link
Member

All Submissions:

Changes proposed in this Pull Request:

Email content larger than 102kb gets clipped by Gmail. This PR implements a notice to let the user know their content may get clipped if we detect a resulting body larger than 100,000 bytes. This approximation is assuming that the ESP will add extra tags for tracking, footer, etc.

image

It also implements the minifying options to MJML to reduce the chance of clipping. My local tests produced a reduction of 25% of an email with ~100k bytes.

How to test the changes in this Pull Request:

  1. Check out this PR and run npm run build
  2. Send an email using multiple different blocks to make sure the markup is not altered by the minification
  3. Add multiple text blocks in a newsletter draft until it reaches > 100k bytes
  4. Save the draft and confirm you see the notice in the screenshot above

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@miguelpeixe miguelpeixe requested a review from a team March 15, 2022 17:32
@miguelpeixe miguelpeixe self-assigned this Mar 15, 2022
Copy link
Contributor

@dkoo dkoo left a comment

Choose a reason for hiding this comment

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

Email rendering seems okay (except the new WP 5.9 "Row" block seems to not render correctly—perhaps we should disable this block for the newsletter editor?). The length warning is also great and works well upon save.

Issue: I'm seeing this JS console error about the minify option for MJML:

"minify" option is deprecated in mjml-core and only available in mjml cli.

Inspecting the meta value, it does appear to be minified, but I wonder if the above indicates support for this feature might go away at some point?

src/newsletter-editor/editor/index.js Outdated Show resolved Hide resolved
@miguelpeixe
Copy link
Member Author

miguelpeixe commented Mar 22, 2022

except the new WP 5.9 "Row" block seems to not render correctly

Nice catch! I just pushed #772 for this.

Inspecting the meta value, it does appear to be minified, but I wonder if the above indicates support for this feature might go away at some point?

I didn't notice that warning, but unfortunately yes ☹️
We could use the minify option until the next stable major release is out and until then figure out if we'll use a different library for the task. We can also not minify at all and just use the notice. WDYT?

@miguelpeixe miguelpeixe requested a review from dkoo March 22, 2022 19:26
Copy link
Contributor

@dkoo dkoo left a comment

Choose a reason for hiding this comment

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

We could use the minify option until the next stable major release is out and until then figure out if we'll use a different library for the task. We can also not minify at all and just use the notice. WDYT?

This sounds good to me, as long as continuing to use the minify option doesn't end up causing an error on the MJML side. I'm assuming after the option is removed from the library behavior will revert back to what's happening on the current master HEAD, right? Basically the meta value will be saved as unminified HTML again?

@miguelpeixe
Copy link
Member Author

Reading the PR, it just changes the warning message from "is deprecated" to "has been removed" and doesn't apply the htmlMinify(). Shouldn't produce any actual error. The HTML should be stored the same way, only not minified anymore. This will also not affect how the notice interprets the body length.

@miguelpeixe miguelpeixe merged commit 2c1c6a3 into master Mar 22, 2022
@miguelpeixe miguelpeixe deleted the feat/handle-clipable-email-body branch March 22, 2022 20:21
@dkoo
Copy link
Contributor

dkoo commented Mar 22, 2022

That matches my understanding, too—thanks!

matticbot pushed a commit that referenced this pull request Mar 31, 2022
# [1.43.0-alpha.1](v1.42.1...v1.43.0-alpha.1) (2022-03-31)

### Bug Fixes

* disable row group block variation ([#772](#772)) ([82224ff](82224ff))
* move subject back to the sidebar ([#773](#773)) ([46aad75](46aad75))

### Features

* allow theme customization ([#766](#766)) ([ebf3cca](ebf3cca))
* minify and notify clipable email body ([#764](#764)) ([2c1c6a3](2c1c6a3))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 1.43.0-alpha.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request Apr 5, 2022
# [1.43.0](v1.42.1...v1.43.0) (2022-04-05)

### Bug Fixes

* disable row group block variation ([#772](#772)) ([82224ff](82224ff))
* move subject back to the sidebar ([#773](#773)) ([46aad75](46aad75))

### Features

* allow theme customization ([#766](#766)) ([ebf3cca](ebf3cca))
* minify and notify clipable email body ([#764](#764)) ([2c1c6a3](2c1c6a3))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 1.43.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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.

3 participants