0

how to call javascript via if else statement

if (localStorage.getItem('lang')=='zh'){
    //run  javascript prepared for Chinese (not a function but whole javascript file)
}
else {
    //run another javascript file prepared for English
}
12345GG
  • 101
  • 8
  • 4
    Take a look at dynamically including scripts: https://stackoverflow.com/questions/13121948/dynamically-add-script-tag-with-src-that-may-include-document-write – Adam H Jul 18 '18 at 18:27
  • Possible duplicate of [Dynamically add script tag with src that may include document.write](https://stackoverflow.com/questions/13121948/dynamically-add-script-tag-with-src-that-may-include-document-write) – Get Off My Lawn Jul 18 '18 at 18:31
  • If this is node or a [web module](https://medium.com/dev-channel/es6-modules-in-chrome-canary-m60-ba588dfb8ab7), you can use `require('./abc/xyz.js')` – Get Off My Lawn Jul 18 '18 at 18:32

0 Answers0