-
-
Notifications
You must be signed in to change notification settings - Fork 60
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
Why instantiate a new markdown renderer for each file processed? #57
Comments
I forked the code and did a quick hack to instantiate/configure the markdown parser only once. Seems to result in the same output for my limited tests. I have 27 markdown files in my source folder. Not as impressive as I expected the performance difference to be. I guess most of the time is spent in the initial require() commands to load/parse each plugin. Once those are cached, the rest of the overhead in configuring each plugin is minimal. |
May I know what did you change to make this renderer only instantiate once? |
@curbengh As you can see, we require
We also hexo-renderer-markdown-it/lib/renderer.js Line 16 in a4f2be7
We could lift them to the top. |
I assume the rendering process would execute much faster if the Markdown parser was configured once, then used repeatedly. Currently, for each file processed, the renderer is instantiated, all the plugins loaded, and configured, and finally, the text is processed.
Is there a reason for this? Perhaps the plugins or the markdown renderer is stateful?
The text was updated successfully, but these errors were encountered: