Skip to content
This repository has been archived by the owner on Apr 5, 2022. It is now read-only.

FEATURE: Remove jQuery #231

Open
VincentTam opened this issue Mar 6, 2021 · 4 comments
Open

FEATURE: Remove jQuery #231

VincentTam opened this issue Mar 6, 2021 · 4 comments

Comments

@VincentTam
Copy link
Collaborator

Feature Request

Is your feature request related to a problem?

Just a question.

Solution

As in title.

Alternatives

Keep using jQuery

Additional Context

[Add any other context or screenshots about the feature request here.]

@pacollins
Copy link
Owner

I would actually like to dump jQuery for vanilla JS. If I remember correct, the issue is with FancyBox at the moment. I did read they are working on a vanilla JS version.

@VincentTam
Copy link
Collaborator Author

Lemme write an XHR version of

$.ajax({
type: $(this).attr('method'),
url: ['https:/', api, 'v3/entry', gitProvider, username, repo, branch, 'comments'].join('/'),
data: $(this).serialize(),
contentType: 'application/x-www-form-urlencoded',
success: function (data) {
showAlert('success');
setTimeout(function(){ clearForm() }, 3000); // display success message for 3s
$(form).removeClass('loading');
},
error: function (err) {
console.log(err);
showAlert('failed');
$(form).removeClass('loading');
}
});
return false;
});

@VincentTam
Copy link
Collaborator Author

VincentTam commented Mar 11, 2021

I would actually like to dump jQuery for vanilla JS. If I remember correct, the issue is with FancyBox at the moment. I did read they are working on a vanilla JS version.

@pacollins How much IE support do you want? Some function like fetch() isn't IE-compatible, while some like classList.remove() needs ≥ IE10. I find re-inventing the wheel like https://github.com/onweru/hugo-swift-theme/blob/7d940a9e76fd11f4395b90d8f117422f182fb089/assets/js/index.js#L62-L81

  function pushClass(el, targetClass) {
    if (isObj(el) && targetClass) {
      elClass = el.classList;
      elClass.contains(targetClass) ? false : elClass.add(targetClass);
    }
  }

painful. I'm writing a vanilla replacement compatible with IE10.

@pacollins
Copy link
Owner

pacollins commented Mar 11, 2021 via email

@pacollins pacollins changed the title FEATURE: use jQuery slim instead of jQuery FEATURE: Remove jQuery May 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants