Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove jQuery #353

Open
jankapunkt opened this issue Oct 2, 2021 · 15 comments
Open

Remove jQuery #353

jankapunkt opened this issue Oct 2, 2021 · 15 comments
Labels
in-discussion We are still discussing how to solve or implement it
Milestone

Comments

@jankapunkt
Copy link
Collaborator

This has been mentioned from time to time and I'd like to bring this up to seriously discuss it.

Removing jQuery brings some big advantages

  • people tend to avoid Blaze, simply because it's the only dependency to jQuery
  • reduce bundle size by around 70-90 kb
  • do not rely to fix security issues that come with jQuery
  • use browser-builtin standards do not introduce new dependencies or complex custom implementations

There are also some caveits:

  • the DOMBackend basically relies on jquery to parse HTML although this might seem to not be that hard to replace, this still needs a lot of testing and especially integration testing, since this is basically the backbone of Blaze IMO
  • we should first merge Faster fragment parsing #334
  • we need to preserve API, because there are some builtins that heavily work similar to jQuery (like templateInstance.$)

Also there is the question of versioning and if the jQuery removal would really have a breaking impact, which would force us towards a major bump.

What do you think?

@StorytellerCZ
Copy link
Collaborator

Yes, I agree with this move and think that it can be done due to the advancement in JS. I also think that major version bump will be needed and welcomed for this.

@jankapunkt
Copy link
Collaborator Author

Maybe adding to 2.6 a warning that jquery will be removed soon in 3.0.0 or something

@StorytellerCZ
Copy link
Collaborator

We could highlight that in changelog and posts on the forums and so on. I would be against adding it into the code as people seem to be allergic about those kind of warnings (even though that is sometimes the only way to get their attention).

@StorytellerCZ StorytellerCZ added this to the Blaze 3.0 milestone Oct 5, 2021
@harryadel
Copy link
Contributor

I looked into this and actually it might be better to keep it. While some jQuery functions are used here and there like: parseHTML, on, off and jQuery selector which can all be easily replaced with some of the alternatives presented here.

But I believe the main point of using jQuery was to solve this problem which explained in this stackoverflow answer. It's all about browser compatibility so even if we forcibly attempt to remove jQuery we'd end up sacrificing some users since some of the modern browser APIs aren't present in IE8 or IE8 and we'd also need to solve the same problems writing more code which is going to be error prone so why not use something ready and battle tested?

We shouldn't fix what's not broken. If you think about it for a sec, jQuery being used within Blaze doesn't present any real problems at all and it's just our love for new shiny jQuery-less, front-end, frameworks like React and others is what's motivating us for this change so unless there're immediate problems that'd be fixed by removing jQuery it's best to keep it.

@StorytellerCZ
Copy link
Collaborator

I think IE8 is no longer a concern as that one has been discontinued for a while. IE11, finishes this (2022) summer from what I remember, so soon IE won't be a blocker at all. Which means that query selectors can be then used everywhere. As for the other functionality, we will have to weight if it is better to import all of jQuery versus just copying those specific functions.

@vitorflores vitorflores added the in-discussion We are still discussing how to solve or implement it label Jan 3, 2022
@jankapunkt
Copy link
Collaborator Author

The question is, if we can solve this in a way, that we can have jQuery as a drop-in or weak dependency so users, who still really really need this backwards compatibility can still use jQuery.

Also @harryadel I checked some time ago the code for parseHTML and this is actually easily replacable. However, I agree with you, that the event removal is for older browsers an issue and I would also favor to implement a clean event removal (and not rely on the browser in such cases) at template destroy stage.

@distalx
Copy link
Contributor

distalx commented Jan 8, 2022

If we remove the jQuery completely. How would it affect the current usage? i.e. this.$ inside the template API like onRendered and other places. And what would the migration path look like for them when they decide to upgrade to the newer version of the blaze?

@jankapunkt
Copy link
Collaborator Author

I would argue that modern browsers have stable and proven replacements like queryselector.

Handling Dom Element classes, props and events are also now much easier than in the old days.

Maybe we first create a full list of affected functionality and potential replacements to see if this whole idea is even feasible (referring to @harryadel 's comment)

@harryadel
Copy link
Contributor

harryadel commented Jan 8, 2022 via email

@harryadel
Copy link
Contributor

harryadel commented Jan 8, 2022 via email

@harryadel
Copy link
Contributor

harryadel commented Jan 8, 2022 via email

@faburem
Copy link

faburem commented Jul 28, 2022

Is this still planned for the 3.0 release? I have a decent blaze code base for testing and would be happy to help make this happen!

@StorytellerCZ
Copy link
Collaborator

Yes, this is still planned, though it will probably be a while before we get there.

@jankapunkt
Copy link
Collaborator Author

@faburem this will likely to be breaking in case you use the template-level jQuery selectors, like this.$ in onRendered or inside events. We may replace these with native query selectors but we won't be able to preserve the rest of the jquery api

@faburem
Copy link

faburem commented Aug 3, 2022

yes I am fully aware that this is a breaking change! In my project we are using a lot of template-level jQuery selectors so I think it would be a good candidate for testing.
Is there anything I could help you guys with?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in-discussion We are still discussing how to solve or implement it
Projects
None yet
Development

No branches or pull requests

6 participants