-
Notifications
You must be signed in to change notification settings - Fork 644
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
perf: minify runtime comments, remove unnecessary attr quotes #1557
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1557 +/- ##
=======================================
Coverage 90.54% 90.54%
=======================================
Files 355 355
Lines 12759 12759
=======================================
Hits 11552 11552
Misses 1207 1207
Continue to review full report at Codecov.
|
(cherry picked from commit 7a6f802)
@DylanPiercey FYI, this ended up breaking marko snapshots locally since all the attrs were removed. I thought it was a bug in my code somewhere. It probably didn't warrant a major version bump, but can definitely cause builds to fail until updated. |
@redonkulus at the end of the day a snapshot test is going to capture many implementation details of Marko that we don't consider a "public api". We'd expect snapshots to need updating across many releases in Marko 4. The point of snapshot tests though are not to assert that something is working, but to let you know that something has changed. I think developers having to update snapshots during changes like this is acceptable. |
Removing the |
@tigt We may need to revisit that... It technically non-conforming, but the spec does define that it should be parsed as a comment: And we tested it in Safari, FF, Chrome, Edge, and IE: it parses as expected |
Yeah, I’m not aware of any HTML parsers that would refuse to work with it. |
It's tricky. Basically the shorter comments are objectively better since it's just less rendered and shipped code, but tools are going to complain. I think Marko needs to take a stance on if it is more valuable to have output which linters like, or that is more performant / smaller. |
We're reverting the comment change for now. We'll revisit this in the future. |
Is there a way to bring the quotes for attributes' values (that were considered there to be unnecessary) back to the output? There are real cases when quotes are necessary. Maybe, are there some configurable options for that? |
Description
Working toward: #1432
Checklist:
This PR removes unnecessary characters from the html output where possible:
--
from comments since all tested browsers do not require them, for example<!M>
is a treated valid comment.'">
or any space characters can have the quotes removed. Technically the spec says that=
,<
and backticks also need to be escaped, however browsers appear happy to ignore that. The implementation could do better by ensuring the minimum number of escapes by switching between single or double quotes, but for performance reasons instead it will immediately use single quotes when the first double quote is found which works well for most cases.