Replies: 3 comments
-
I like this idea. As someone integrating mermaid into a web-based editor, I think the benefits of lazy-loading diagrams (reduced bundle size, faster initialization time, etc) outweigh the cons (flash of unstyled content, delayed rendering).
Using dynamic chunks could avoid this problem. Instead, the initialization of each of these diagrams could be based on boolean configurations. E.g. // on init
mermaid.initialize({
diagrams: {
flowchart: true,
mindmap: true,
sequence: true,
},
})
// pseudo init resolution
if (config.diagrams.flowchart) {
const { id, detector, loader } = await import('./flowchart')
addDiagram({ id, detector, loader })
} A public API for registering diagrams in mermaid could also help solve these issues though. Then, you could theoretically have multiple bundles available that build on top of each other.
|
Beta Was this translation helpful? Give feedback.
-
Is there documentation of how to make a new diagram type that is then lazy loaded? |
Beta Was this translation helpful? Give feedback.
-
How do I specify which of the diagrams to enable? Is the feature supported? |
Beta Was this translation helpful? Give feedback.
-
We want to add more diagram types to Mermaid and more layout options for flowcharts etc. We have been somewhat reluctant to do this on a bigger scale as the backside of this is that the bundle will grow. With enough features and diagrams it will likely grow considerably.
To counter this we are adding the ability to load diagrams dynamically when required instead of having all diagrams in one big bundle. We are eager to get the details of this right before we lock down the API and the functionality.
In release 9.2 lazy loading with a beta API is released.
There are a few things that are worth considering.
We are looking for feedback:
Beta Was this translation helpful? Give feedback.
All reactions