diff --git a/addon/initializers/load-socketcluster-client.js b/addon/initializers/load-socketcluster-client.js index 63981f0..90e6c68 100644 --- a/addon/initializers/load-socketcluster-client.js +++ b/addon/initializers/load-socketcluster-client.js @@ -1,9 +1,14 @@ export function initialize() { - const socketClusterClientScript = document.createElement('script'); - socketClusterClientScript.src = '/assets/socketcluster-client.min.js'; - document.body.appendChild(socketClusterClientScript); + // Check if the script already exists + // Only insert the script tag if it doesn't already exist + if (!document.querySelector('script[data-socketcluster-client]')) { + const socketClusterClientScript = document.createElement('script'); + socketClusterClientScript.setAttribute('data-socketcluster-client', '1'); + socketClusterClientScript.src = '/assets/socketcluster-client.min.js'; + document.body.appendChild(socketClusterClientScript); + } } export default { initialize, -}; +}; \ No newline at end of file