the javascript contains over 200 lines of code optimize the function below for best performance
  createMenuListing(id) {
    const ACABM = this;
    const { settings } = ACABM;
    const value = settings[id];
    const settingsid = id;
    const { name, description, values } = ACABMmenuDictionary[id];
    const UPPids = [227];

    var listing = document.createElement("div");
    listing.className = "listing";

    var a = document.createElement("a");

    a.className = `smallFancyButton prefButton option${
      value > 0 ? "" : " off"
    }`;
    a.innerText = `${name} ${values[value]}`;
    a.onclick = function () {
      const newValue = (value + 1) % Object.entries(values).length;
      settings[id] = newValue;

      if (
        settingsid === "autobuy" &&
        settings[id] &&
        settings.options.indexOf("ABExpand") == -1
      ) {
        settings.options.push("ABExpand");
      }

      if (
        settingsid === "wrinklers" &&
        settings[id] &&
        settings.options.indexOf("AWExpand") == -1
      ) {
        settings.options.push("AWExpand");
      }

      if (
        settingsid === "gold" &&
        settings[id] &&
        settings.options.indexOf("AGExpand") == -1
      ) {
        settings.options.push("AGExpand");
      }

      PlaySound("snd/tick.mp3");
      Game.UpdateMenu();
    };

    listing.appendChild(a);

    if (settingsid === "autobuy") {
      var a = document.createElement("a");
      a.className = `smallFancyButton`;
      a.innerText = `${
        settings.options.indexOf("ABExpand") != -1
          ? "Collapse Options"
          : "Expand Options"
      }`;
      a.onclick = function () {
        if (settings.options.indexOf("ABExpand") != -1) {
          settings.options.splice(settings.options.indexOf("ABExpand"), 1);
        } else {
          settings.options.push("ABExpand");
        }
        PlaySound("snd/tick.mp3");
        Game.UpdateMenu();
      };
      listing.appendChild(a);
    }

    if (settingsid === "wrinklers") {
      var a = document.createElement("a");
      a.className = `smallFancyButton`;
      a.innerText = `${
        settings.options.indexOf("AWExpand") != -1
          ? "Collapse Options"
          : "Expand Options"
      }`;
      a.onclick = function () {
        if (settings.options.indexOf("AWExpand") != -1) {
          settings.options.splice(settings.options.indexOf("AWExpand"), 1);
        } else {
          settings.options.push("AWExpand");
        }
        PlaySound("snd/tick.mp3");
        Game.UpdateMenu();
      };
 