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(nuxt): ensure renderHTMLDocument
return more compact result
#24888
Conversation
Run & review this pull request in StackBlitz Codeflow. |
renderHTMLDocument
return more compact resultrenderHTMLDocument
return more compact result
CodSpeed Performance ReportMerging #24888 will degrade performances by 39.95%Falling back to comparing Summary
Benchmarks breakdown
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if these changes will have a significant impact after text compression. GZIP/brotli should cover a lot of that already.
Would be interesting to see benchmarks on the standard application as well as "more real-life" project (e.g. something like https://github.com/nuxt/movies)
(As the refactoring here doesn't hurt readability significantly either I'm not opposed to merging btw)
re: extra spaces in Yes, please! Every time I see this I want to send a PR but have been avoiding the distraction re: removing all line-breaks In my experience, the saving % with compression isn't worth the loss of being able to easily debug page source. If you have benchmarks on the contrary then please share. If you want smaller HTML then leaning into it and fully minifying the HTML will give you better results, which should already be easy to do via a nitro plugin. Have no issues with this being an opt-in core feature though. This is the same thinking I have with unjs/unhead#297, which I'm happy to accept as an opt-in if we want to go in that direction. |
Thank you for your valuable feedback. However, I would like to seek some clarification: Are you suggesting the addition of an option in Currently, I am integrating the Nitro plugin with Nevertheless, I am curious about how the removal of newline characters might impact debugging, as I generally rely on Chrome DevTools for this purpose. |
Thank you for your feedback. I may need to explore how to test this change within the |
Yes, for both. Ideally, the I think if you want to tackle this, you should do it in a separate PR and just keep this one simple, focusing on the extra unneeded spaces.
There are instances where you need to see the actual SSR DOM response instead of the client-hydrated DOM, especially when dealing with hydration issues. |
Sure! I will attempt to add an option to unjs/unhead#297 that allows developers to decide whether to remove newline characters based on their needs. |
I have tried to compare the differences before and after this PR using the Nuxt Movies project. From the Response Headers provided by Chrome DevTools, I found Before After Perhaps this cannot be classified as an improvement. π |
@Mini-ghost Thanks for the effort! Yeah, not a huge thing but if it won't decrease perf or increase code complexity it is fine for me ππ» |
π Linked issue
Resolve #23085
β Type of change
π Description
I have attempted to minimize the size of the generated HTML by eliminating unnecessary line breaks where possible. Below is the HTML output from the current version after executing
nuxi generate playground
:The adjusted versions are as follows:
The extent of reduction is quite limited, primarily due to the fact that most of the
<head>
content is generated by@unhead/ssr
, which might be beyond the scope of Nuxt.I am open to feedback regarding whether this adjustment will yield significant benefits. Should the evaluation indicate that the drawbacks outweigh the benefits, please feel free to close this PR.
π Checklist