Skip to content

Commit

Permalink
make sure socketcluster client script is only added to document once
Browse files Browse the repository at this point in the history
  • Loading branch information
roncodes committed Mar 2, 2024
1 parent e9f4dc4 commit dd3b803
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions addon/initializers/load-socketcluster-client.js
Original file line number Diff line number Diff line change
@@ -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,
};
};

0 comments on commit dd3b803

Please sign in to comment.