Some website are build in an approach called Single Page Application
(abbreviated SPA). this methodology avoids page navigation and page refresh in favor of pseudo navigation using the HTML5
History API or through the older hash portion of the url,
without actually navigating away from the page. checkout our PWA guide for more information.

When watching multiple videos without navigating and reloading the page, it's possible that a user will be connected to irrelevant peers and will have lower P2P efficiency. To solve this use case peer5 exposes .init()/.destroy() methods that effectively resets Peer5 and allows proper P2P flow on continuous sessions.

When loading Peer5 script it's already initialized so there is no need to call init when loading.
Whenever the user navigated to another section of the SPA or even when switching to a different video,
.init() and .destroy() should be called. You may call peer5.isInitialized() in order to check whether or not Peer5 is currently initialized or not.

NOTE: It's important to call .destroy() after destroying the player and .init() before creating the new player instance.