Many of us started out with jquery. It is truly a great library that has made javascript development much easier and more convenient. We should realize that the library provides a set of tools that are designed to help developers with everyday problems – DOM tree manipulation, event handling, animations, working with ajax, etc. We are so used to this tool that we use it everywhere.
Javascript is a multi-paradigm programming language, and it provides several approaches to implementing applications. You can use both object-oriented approach and functional approach (which is the most popular in this language nowadays). In addition, the language has an event-driven model, without which it is difficult to imagine the development of any user interface. There is no escape from the procedural style.
It so happens that in the minds of developers who often use jquery in their projects (especially those who started with jquery), a single principle of writing applications is firmly planted:
- find the right DOM element in the tree;
- bind to it the necessary event handlers;
- write code in the events that changes the DOM;
- repeat.
But this scheme, despite the fact that it has many advantages (ease of understanding, clarity, low threshold of entry) has a number of significant disadvantages:
- as the application grows, the amount of code increases exponentially;
- duplication and a lot of redundant and/or global functions inevitably appear;
- inconvenience (or even impossibility) of reuse;
- complication of support and development;
- on serious projects it starts to noticeably slow down the overall performance.
The modular approach to development is aimed at solving these problems. You just need to rethink the rules and principles that have been professed for many years and look in the direction of something new, not to tread on the ground.
Just don’t think that jquery is bad. You can write perfectly structured, modular code with its help, but it requires a bit more effort than just the noodles we are so used to.