-
-
Notifications
You must be signed in to change notification settings - Fork 407
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
Minify JSON-LD markup result #802
Conversation
Do you have any benchmark or test to see the differences @akshatmittal! Love this fix, trying to make everything more small and fast! |
@riccardogiorato I don't have a benchmark, but I do have an example if you'd like. I use this plugin on one of my website and the current result looks something like this:
Yep, as you can see it does have all of those whitespaces and what not in the markup itself. With this fix, the final result looks like this:
And all of this with no impact on how search engines and bots would parse it! |
Hey @akshatmittal thanks for the PR. We did have a feature like this live and had to revert due to it causing issues.
I do wonder what is the performance cost of the browser parsing extra newlines versus having to run JavaScript such as You can see the original PR here: #487 I am open to solving this issue, just need to make sure the fix is valid and not counter productive. 😅 |
Hey @garmeeh, thanks for that! I didn't know that existed but was reverted. I definitely think this is valuable and both of the bugs linked are caused by unhandled escapes. I will probably look deeper into this in a little bit (yes, I really want the minified JsonLd). And yea, that |
@garmeeh So as it turns out, neither of the linked bugs are actually minify bugs to begin with. No text in the entire codebase is ever escaped, and directly creates a At the moment, my recommendation would be to not merge this change. The I do think it would be quite worth it to rewrite the entire library to use Objects instead of string builders. Edit: Going back, it looks like the unescaped strings are causing issues for a lot of other people as well. |
Thanks for the insight @akshatmittal. Yeah when I first built next-seo it was under the assumption it would only be passed valid data. But in hindsight this might this may have been a bad choice 😅 In your mind what would it look like using JSON objects instead? Maybe you could give a small example of what you are thinking? I can try evaluate the effort in re-writing and also if it can be done incrementally. There are few other things that I could tackle during the re-write also. |
Here's an example @garmeeh, the current
Then passed on as Any variable not passed to the React component will be The effort is definitely significant since it basically replaces ALL the files, but can be done incrementally. If you do plan on tackling other issues, I'd also highly recommend strongly typing the components. |
Definitely interested in this feature! Using JSON objects would also allow for more extensibility. Currently, the schemas can be a bit limiting, and in case some additional properties are needed, you're out of luck. |
Thanks @akshatmittal. I really like this approach and it will simplify things. I will carry out a test on this approach next week and see what will be involved in re-writing. |
Ok so I have tested this out and it works pretty well. I am currently planning out the re-write as there are other changes I would like to make and upgrades to the project codebase I want to make at the same time. I am pretty busy at work at the moment and have some holidays coming up but will try my best to get this out ASAP. |
If you need a hand, someone to help with the change over I can get on a call with you one day and help you tackle some files? |
Thanks everyone for baring with me on this one. 😅
|
Description of Change(s):
JSON-LD Markup can be minified without any effect on parsing capabilities. This also solves the extra newlines issues present in most markups.