Why can't I do a typing effect on the warehouse theme (shopify)?

This is my JS CODE : The code is good but why can’t I add it to my warehouse theme?

/* Barre Dynamique */
function typingEffect() {
  
  const textes = [
    {
      text: "des prix attractifs !"
    },
    {
      text: "la livraison gratuite !"
    },
    {
      text: "une garantie satisfait ou remboursé !"
    },
    {
      text: "un service après vente de qualité !"
    },
    // mettre ici 
  ];
  
  /* Pour rajouter un texte mettez au niveau du 'mettre ici' le code entre les --- ci-dessous:
  ---
  {
    text: "autre texte"
  },
  ---
  */

  let phrases = [x];
  textes.map(item => phrases.push(item.text));
  
  const text = document.getElementById("typing-effect");
  let counter = 0;
  let currentIndex = getRandomInt(0, phrases.length - 1);
  let stepInterval = setInterval(() => { step(); }, 100);
  let delInterval;
  let delTimeout;

  function getRandomInt(min, max) {
    min = Math.ceil(min);
    max = Math.floor(max);
    return Math.floor(Math.random() * (max - min + 1)) + min;
  }

  function delIntervalCallback(){
    delInterval = setInterval(() => { del(); }, 50);
    clearTimeout(delTimeout);
  }

  function del(){
    if(counter == 0){
      let newIndex = getRandomInt(0, phrases.length - 1);
      while(newIndex == currentIndex){
        newIndex = getRandomInt(0, phrases.length -1 );
      }
      currentIndex = newIndex;
      clearInterval(delInterval);
      return stepInterval = setInterval(() => { step(); }, 50);
    }
    text.textContent = text.textContent.slice(0, -1)
    counter--;
  }

  function step(){
    if(counter >= phrases[currentIndex].length){
      clearInterval(stepInterval);
      return delTimeout = setTimeout(() => { delIntervalCallback(); }, 2000);
    }
    text.textContent += phrases[currentIndex][counter];
    counter++;
  }
}

typingEffect();

Have you googled how to add JS to Shopify. A quick search tells me there’s a Shopify Script Editor for this purpose. Have you tried that?

When I program my entire code it works with all themes except with the theme warehouse. A problem with JS and warehouse function accounting

Have you checked the error console? Maybe a script conflict?


Message of my console

I should have thought the first two errors at least needed your attention.

How does that compare with the console on themes where your scripts work?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.