-
Notifications
You must be signed in to change notification settings - Fork 445
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: Optimize js file loading condition and order #683
base: master
Are you sure you want to change the base?
Conversation
Thanks so much for opening your first PR here! |
Pull Request Test Coverage Report for Build 6130948666
💛 - Coveralls |
7b8b098
to
a62a2e6
Compare
After waking up, I realized there was a small issue with the conditions for loading comments. Previously it was |
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.
Scripts like https://github.com/next-theme/hexo-theme-next/blob/master/source/js/third-party/analytics/google-analytics.js are loaded in <head>
and requires CONFIG
variable
a62a2e6
to
472000f
Compare
Emm, didn't notice that, looks like it requires more changes than I thought before. For now I will just delete the changes about config.js. Please have a look again. |
@@ -1,6 +1,8 @@ | |||
{%- include 'vendors.njk' -%} | |||
|
|||
{{- next_js('comments.js') }} | |||
{%- if theme.injects.comment.length > 0 %} |
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.
Actually, the condition could be '> 1' because if there's only one comment system, it doesn't have to switch
PR Checklist
PR Type
What is the current behavior?
Issue resolved:
source/js/comments.js
will included in html even if none of the comment systems is enabled.source/js/config.js
is inside the head tag, which will block the rendering, but it doesn't have to.What is the new behavior?
source/js/comments.js
will not be included in html if none of the comment system is using.source/js/config.js
is now at the end of the body tag, right after the vendor scripts and before all the next script, which won't block the DOM rendering and everything works just like before.How to use?
Disable all the comment system or enable some of them in NexT
_config.yml
.