Skip to content

Commit

Permalink
wait for client before document get
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiggr committed Jan 13, 2023
1 parent 54ceee4 commit e12a3db
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@ const loadTableauScript = (callback, version) => {

const isMyScriptLoaded = (version) => {
//check for loaded Tableau script in dom scripts
var scripts = document.getElementsByTagName('script');
for (var i = scripts.length; i--; ) {
// eslint-disable-next-line eqeqeq
if (
scripts[i].src ===
`https://public.tableau.com/javascripts/api/tableau-${version}.min.js`
)
return true;
var scripts = __CLIENT__ && document.getElementsByTagName('script');
if (scripts) {
for (var i = scripts.length; i--; ) {
// eslint-disable-next-line eqeqeq
if (
scripts[i].src ===
`https://public.tableau.com/javascripts/api/tableau-${version}.min.js`
)
return true;
}
}
return false;
};
Expand Down

0 comments on commit e12a3db

Please sign in to comment.