-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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(meta_generator.js): Do not check if meta_generator has been injected before. #4078
perf(meta_generator.js): Do not check if meta_generator has been injected before. #4078
Conversation
You see, maybe the theme has already inserted the Also, manipulating |
You're right. However, this case is rare, and duplicate meta tags do not cause any problems. |
What does it mean? |
@dailyrandomphoto Although simply changing Also, I have tested the performance impact of registered filter. As you can see, |
Based on this, I have already added a cache in my #4070 in order to make sure return early before |
This PR does not write config back to The main change for this PR is - || data.match(/<meta([\s]+|[\s]+[^<>]+[\s]+)name=['|"]?generator['|"]?/i)) |
We could only call |
@@ -24,15 +24,15 @@ describe('Meta Generator', () => { | |||
resultType.should.eql('undefined'); | |||
}); | |||
|
|||
it('no duplicate generator tag', () => { | |||
it.skip('no duplicate generator tag', () => { |
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 would prefer to retain the tests. it is possible for theme to have any of these mistakes, we need to account for them so that we don't make it worse.
This PR might be superseded by #4208. |
#4208 merged |
What does it do?
Fix #4056 . Related #4070, #3129, #3315, #4051, #4048.
meta_generator.js
was introduced in #3129.Why do we need to check if meta_generator has been injected before?
Because while generating an HTML, the
after_render:html
filter will be executed many times at rendering .md file, partial files, so generator meta tag will be injected multiple times. (See #4048.)Another filter,
after_route_render
, was introduced in #4051, which ensures that the meta_generator is executed once per HTML. Therefore, this check is no longer needed, and performance is improved without it.How about if
meta_generator()
helper was used?Set
meta_generator: false
in_config.yml
.The previous regex was introduced in #3697 which ignores empty tags.
The
empty <head> tags
appears becausecheerio
andafter_render:html
filter are used.The
after_render:html
filter makes rendered results of partial files processed bymeta_generator.js
, and when a third-party plugin uses cheerio 1.0.0-rc.1+,<html><head><body>
are automatically added to the rendered results of partials.As the use of
after_route_render
and removal ofcheerio
,empty <head> tags
no longer need to be considered.Commit history of
meta_generator.js
: part 1 part 2How to test
Pull request tasks