Skip to content

Remove jQuery Dependecy #201

@thsmi

Description

@thsmi

With modern browsers the need for jquery is gone.

http://youmightnotneedjquery.com/
https://tobiasahlin.com/blog/move-from-jquery-to-vanilla-javascript/#selecting-elements

So it should be removed to reduce the footprint.
Especially as the next Bootstrap Release does not depend on jQuery anymore.

  • Replace .text() with .textContent
// jquery
item.find(".sieve-settings-port").text(account.port);

// vanilla.js
elm.querySelector(".sieve-settings-port")
  .textContent = account.port;
  • Replace .click() handlers with .addEventListener()
// jquery
item.find(".sieve-account-delete-server").click(() => { this.remove(); });

// vanilla.js
elm.querySelector(".sieve-account-delete-server")
  .addEventListener("click", () => { this.remove(); });
  • Replace .remove()
// jquery
$("#something").remove()

// vanilla.js
const elm = elm.querySelector("#something")
elm.parentNode.removeChild(elm);
  • Replace .empty()
// jquery
$(`#siv-account-${this.id} .siv-tpl-scripts`)
  .empty()
  .append(item);

// vanilla.js
const scripts = document.querySelector(`#siv-account-${this.id} .siv-tpl-scripts`);
while (scripts.firstChild)
  scripts.removeChild(scripts.firstChild);

scripts.appendChild(item);
  • replace .show()
//jquery
parent.find(".siv-settings-advanced").show();

// vanilla.js
parent.querySelector(".siv-settings-advanced").style.display = "";
  • replace .hide()
//jquery
parent.find(".siv-settings-advanced").hide();

// vanilla.js
parent.querySelector(".siv-settings-advanced").style.display = "none";
  • replace .find()

  • Replace templateloader.load with templateloader.replace(id,url) and templateloader.append(id,url)

  • replace .replaceWith()

// jquery
item.replaceWith(this.html(true));

// vanilla.js
item.parent.replaceChild(this.html(true), item);

Metadata

Metadata

Assignees

Labels

AppIssue affects the standalone applicationWebExtensionIssue affects Thunderbird WebExtensionenhancement

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions