feat: Conditionally load Mermaid.js#2
Conversation
This change modifies the post layout to only include the Mermaid.js script if the post content contains a Mermaid diagram. This is achieved by checking for the presence of the "language-mermaid" string in the post's content. This change improves page load performance by avoiding the unnecessary loading of the Mermaid.js library on pages that do not contain any diagrams.
Summary of ChangesHello @donglua, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request implements a performance optimization by introducing conditional loading for the Mermaid.js library. Instead of including the script on every post page, it will now only be loaded when a post is detected to contain a Mermaid diagram. This targeted approach ensures that resources are only consumed when necessary, leading to faster page rendering for content without diagrams. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a good performance optimization by loading Mermaid.js conditionally, only when a diagram is present in the post content. The approach of checking for the 'language-mermaid' string is a sensible and pragmatic way to achieve this. My review includes one suggestion to improve code formatting for better readability and consistency.
|
|
||
| {% include mermaid.html %} No newline at end of file | ||
| {% if content contains 'language-mermaid' %} | ||
| {% include mermaid.html %} |
This change modifies the post layout to only include the Mermaid.js script if the post content contains a Mermaid diagram. This is achieved by checking for the presence of the "language-mermaid" string in the post's content. This change improves page load performance by avoiding the unnecessary loading of the Mermaid.js library on pages that do not contain any diagrams.