Skip to content

Plugin Loading #3098

Answered by hakimel
AhmedThahir asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, you can lazy or conditionally load plugins but you will need to call Reveal.registerPlugin to register them.

Here's an example:

Reveal.initialize();

const loadScript = src => {
  return new Promise((resolve, reject) => {
      const script = document.createElement('script');
      script.type = 'text/javascript';
      script.onload = resolve;
      script.onerror = reject;
      script.src = src;
      document.head.append(script);
  })
}

loadScript( 'plugin/highlight/highlight.js' ).then(() => {
  Reveal.registerPlugin( RevealHighlight )
})

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by AhmedThahir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants
Converted from issue

This discussion was converted from issue #3097 on December 17, 2021 12:08.