perf: Optimize comments.js file loading condition#683
perf: Optimize comments.js file loading condition#683stevenjoezhang merged 2 commits intonext-theme:masterfrom
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 |
stevenjoezhang
left a comment
There was a problem hiding this comment.
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. |
layout/_scripts/index.njk
Outdated
| {%- include 'vendors.njk' -%} | ||
|
|
||
| {{- next_js('comments.js') }} | ||
| {%- if theme.injects.comment.length > 0 %} |
There was a problem hiding this comment.
Actually, the condition could be '> 1' because if there's only one comment system, it doesn't have to switch
|
This PR is breaking the comments plugin: https://github.com/next-theme/hexo-next-valine/blob/841534244f0cb28e043316d533b3c8137ebd4eb2/index.js#L33
|
It's working now! |
|
For now, I'm using below package.json😂:
I created a PR to the original repo. |


PR Checklist
PR Type
What is the current behavior?
Issue resolved:
source/js/comments.jswill included in html even if none of the comment systems is enabled.source/js/config.jsis inside the head tag, which will block the rendering, but it doesn't have to.What is the new behavior?
source/js/comments.jswill not be included in html if none of the comment system is using.source/js/config.jsis 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.