Should I still continue using JQuery for Bootstrap 5 when it's no longer a requirement?
The latest Bootstrap 5 version is designed to no longer depend on JQuery but you can still use it. In the Bootstrap website they encourage you to use vanilla JavaScript.
I have always used JQuery in my previous Bootstrap versions and am in two minds about switching to vanilla JavaScript and abandoning JQuery altogether.
I understand that the main advantage is that you save around 85k by not importing the JQuery library but the trade-off is the code is not as easy to read. I am also concerned that I still depend on plug-ins such as Fancybox which depend on JQuery so I would have to import it anyway.
I would like your views on the best approach going forward based on what I have written.
Where JQuery is concerned... generally speaking...
1) You'll either use JQuery where this makes sense... or...
2) Write your own JQuery replacement code, which will almost surely work slower, less correctly, with far larger sized code than using JQuery.
There is no right or wrong.
You'll have to make this choice based on your own criteria for robustness of your code.
In almost every case, JQuery code (1000s of developers) will be far more robust code than any single person can write.
lenamtl
Hi,
I just bought my first Bootstrap 5 template with no JS dependencies.
What I have realized with this, this is using very old JS to achieve the usual jQuery stuff most are old JS, no longer maintained and maybe not secure.
So the template is a bit buggy because of this.
So I added jQuery to be able to use more robust plugins.
For a web application I would use jQuery for sure.
Maybe we are in a new turn, big players try to change the trend but sometimes the dev just don't follow ...
Miguel Oz
It depends what you use in your website. For example is you use Angular, you can use Bootstrap 5 without using JQuery as most of the Angular libraries do not require JQuery.
1) You'll either use JQuery where this makes sense... or...
2) Write your own JQuery replacement code, which will almost surely work slower, less correctly, with far larger sized code than using JQuery.
There is no right or wrong.
You'll have to make this choice based on your own criteria for robustness of your code.
In almost every case, JQuery code (1000s of developers) will be far more robust code than any single person can write.