Javascript does not work on mobile and tablet

Hi,
I am having trouble with my Javascript file that does not seem to work on any other devices than desktop. At first, I thought that this was a problem within the script or with how it was linked to the HTML file but found that everything works perfectly fine except when I used my tablet and mobile to test the site. I have also tried to download the most recent deploy and saw that the app.js file was not missing.

Can someone please help me detect the problem?

This is my site’s name: gingergrass.netlify.app
And this is my Github repo: GitHub - vi-lepham/gingergrass-website: Brochure site for Ginger Grass Thai Vietnamese restaurant

Thank you!

interesting! Are the mobile devices using wifi (the same wifi as the desktop) or on a different network/ISP?

Hi Perry!
They are all using the same wifi!

Hey @vilepham,
I checked out your repo and this is likely an issue with which mobile browsers support ES6. You’ll need to remove your ES6 code or add polyfills for browsers that don’t support. Here’s a post that mentions a similar issue:

This site can be useful for checking compatibility:

Let us know if this helps or if you have any other questions about deploying on Netlify!

I removed the ES6 code and it worked!
Thank you so much!!

1 Like

Hi, I tried this solution but nothing changed…

I’ll leave my app.js here if anyone wants to help me:

const allCharacters = [β€œA”,β€œB”,β€œC”,β€œD”,β€œE”,β€œF”,β€œG”,β€œH”,β€œI”,β€œJ”,β€œK”,β€œL”,β€œM”,
β€œN”,β€œO”,β€œP”,β€œQ”,β€œR”,β€œS”,β€œT”,β€œU”,β€œV”,β€œW”,β€œX”,β€œY”,
β€œZ”,β€œa”,β€œb”,β€œc”,β€œd”,β€œe”,β€œf”,β€œg”,β€œh”,β€œi”,β€œj”,β€œk”,β€œl”,
β€œm”,β€œn”,β€œo”,β€œp”,β€œq”,β€œr”,β€œs”,β€œt”,β€œu”,β€œv”,β€œw”,β€œx”,β€œy”,
β€œz”, β€œ0”,β€œ1”, β€œ2”, β€œ3”, β€œ4”, β€œ5”, β€œ6”, β€œ7”, β€œ8”, β€œ9”,
β€œ~”,β€œ`”,β€œ!”,β€œ@”,β€œ#”,β€œ$”,β€œ%”,β€œ^”,β€œ&”,β€œ*”,β€œ(”,β€œ)”,β€œ_”,
β€œ-”,β€œ+”,β€œ=”,β€œ{”,β€œ[”,β€œ}”,β€œ]”,β€œ,”,β€œ|”,β€œ:”,β€œ;”,β€œ<”,β€œ>”,
β€œ.”,β€œ?”,β€œ/”];

const withSymbols = [β€œA”,β€œB”,β€œC”,β€œD”,β€œE”,β€œF”,β€œG”,β€œH”,β€œI”,β€œJ”,β€œK”,β€œL”,β€œM”,
β€œN”,β€œO”,β€œP”,β€œQ”,β€œR”,β€œS”,β€œT”,β€œU”,β€œV”,β€œW”,β€œX”,β€œY”,β€œZ”,
β€œa”,β€œb”,β€œc”,β€œd”,β€œe”,β€œf”,β€œg”,β€œh”,β€œi”,β€œj”,β€œk”,β€œl”,β€œm”,
β€œn”,β€œo”,β€œp”,β€œq”,β€œr”,β€œs”,β€œt”,β€œu”,β€œv”,β€œw”,β€œx”,β€œy”,β€œz”,
β€œ~”,β€œ`”,β€œ!”,β€œ@”,β€œ#”,β€œ$”,β€œ%”,β€œ^”,β€œ&”,β€œ*”,β€œ(”,β€œ)”,β€œ_”,
β€œ-”,β€œ+”,β€œ=”,β€œ{”,β€œ[”,β€œ}”,β€œ]”,β€œ,”,β€œ|”,β€œ:”,β€œ;”,β€œ<”,β€œ>”,
β€œ.”,β€œ?”,β€œ/”];

const withNumbers = [β€œA”,β€œB”,β€œC”,β€œD”,β€œE”,β€œF”,β€œG”,β€œH”,β€œI”,β€œJ”,β€œK”,β€œL”,β€œM”,
β€œN”,β€œO”,β€œP”,β€œQ”,β€œR”,β€œS”,β€œT”,β€œU”,β€œV”,β€œW”,β€œX”,β€œY”,β€œZ”,
β€œa”,β€œb”,β€œc”,β€œd”,β€œe”,β€œf”,β€œg”,β€œh”,β€œi”,β€œj”,β€œk”,β€œl”,β€œm”,
β€œn”,β€œo”,β€œp”,β€œq”,β€œr”,β€œs”,β€œt”,β€œu”,β€œv”,β€œw”,β€œx”,β€œy”,β€œz”,
β€œ0”,β€œ1”, β€œ2”, β€œ3”, β€œ4”, β€œ5”, β€œ6”, β€œ7”, β€œ8”, β€œ9”]

const onlyLetters = [β€œA”,β€œB”,β€œC”,β€œD”,β€œE”,β€œF”,β€œG”,β€œH”,β€œI”,β€œJ”,β€œK”,β€œL”,β€œM”,
β€œN”,β€œO”,β€œP”,β€œQ”,β€œR”,β€œS”,β€œT”,β€œU”,β€œV”,β€œW”,β€œX”,β€œY”,β€œZ”,
β€œa”,β€œb”,β€œc”,β€œd”,β€œe”,β€œf”,β€œg”,β€œh”,β€œi”,β€œj”,β€œk”,β€œl”,β€œm”,
β€œn”,β€œo”,β€œp”,β€œq”,β€œr”,β€œs”,β€œt”,β€œu”,β€œv”,β€œw”,β€œx”,β€œy”,β€œz”]

const btnEl = document.getElementById(β€œbtn-el”);
const firstPass = document.getElementById(β€œpassword1”);
const secondPass = document.getElementById(β€œpassword2”);

/* CHECKBOX */
const inputNumbers = document.getElementById(β€˜numbers’);
const inputSymbols = document.getElementById(β€˜symbols’);

/* Copy Icon */
const copyIcons = document.querySelectorAll(β€˜i’);

/* Take Slider Value */
const lengthSlider = document.getElementById(β€˜lengthSlider’);
const lengthP = document.getElementById(β€˜lengthP’);

lengthSlider.addEventListener(β€˜mousemove’, () => {
lengthP.textContent = lengthSlider.value
})

//Generate Button
btnEl.addEventListener(β€˜click’, randomPass);

//Copy Icon Event Listener
copyIcons.forEach(copyIcon => {
copyIcon.addEventListener(β€˜click’, copyText);
})

/* Random Password Generator */
function randomPass() {
firstPass.textContent = " ";
secondPass.textContent = " ";
//Selected length
let length = lengthSlider.value

/* No Numbers /
if (!inputNumbers.checked && inputSymbols.checked) {
for(let i = 0; i < length; i++) {
let shuffle1 = Math.floor(Math.random() * withSymbols.length);
let shuffle2 = Math.floor(Math.random() * withSymbols.length);
firstPass.textContent += withSymbols[shuffle1];
secondPass.textContent += withSymbols[shuffle2];
}
/
No Symbols /
} else if (inputNumbers.checked && !inputSymbols.checked) {
for(let i = 0; i < length; i++) {
let shuffle1 = Math.floor(Math.random() * withNumbers.length);
let shuffle2 = Math.floor(Math.random() * withNumbers.length);
firstPass.textContent += withNumbers[shuffle1];
secondPass.textContent += withNumbers[shuffle2];
}
/
Only Letters /
} else if (!inputNumbers.checked && !inputSymbols.checked) {
for(let i = 0; i < length; i++) {
let shuffle1 = Math.floor(Math.random() * onlyLetters.length);
let shuffle2 = Math.floor(Math.random() * onlyLetters.length);
firstPass.textContent += onlyLetters[shuffle1];
secondPass.textContent += onlyLetters[shuffle2];
}
/
All char */
} else {
for(let i = 0; i < length; i++) {
let shuffle1 = Math.floor(Math.random() * allCharacters.length);
let shuffle2 = Math.floor(Math.random() * allCharacters.length);
firstPass.textContent += allCharacters[shuffle1];
secondPass.textContent += allCharacters[shuffle2];
}
}
}

function copyText() {
const text = firstPass.textContent;
navigator.clipboard.writeText(text)
}