twbs / bootstrap

The most popular HTML, CSS, and JavaScript framework for developing responsive, mobile first projects on the web.
https://getbootstrap.com
MIT License
170.88k stars 78.88k forks source link

Remove `jquery` from required packages #23204

Closed klimov-paul closed 7 years ago

klimov-paul commented 7 years ago

Relates to #22194

jQuery should be removed from the mandatory dependencies for Bootstrap library.

Since Bootstrap is posioned as CSS framework (not JS one) and it is declared it can function without JQuery (even while it is limiting its features), there should be a way to install pure Bootstrap without JQuery from the repositories like Bower/Npm.

In particular, these lines should be removed: https://github.com/twbs/bootstrap/blob/v4-dev/bower.json#L34-L35

In the modern web application development more and more projects relies on suhc JS libraries like AngularJS, ReactJs, EmberJS and so on, in pursuit for 'on-page-site' feature implementation.

If particular developer wishes to use AngularJS and Bootstrap, why should he install a 'jquery' package, which will lie as a garbage among the project source files? Keeping 'jquery' as mandatory dependency looks unprofessional.

Ideally JS related code should be moved into a separated repository, which will depend on 'twbs/bootstrap' and 'jquery', while 'twbs/bootstrap' itself will be requirement free.

If this be a Composer installation, the quick solution will be move 'jquery' into suggest section, but for Bower/Npm - I can not say.

mdo commented 7 years ago

I'd have to talk to the @twbs/team—hi folks, please weigh in!—but you're initial premise is inaccurate. From our homepage, we say HTML, CSS, and JS framework. Part of the appeal (and criticism, I realize) is in the all-in-one nature of our project.

mdo commented 7 years ago

Also, this is a breaking change, so we have to decide now or wait until v5.

Johann-S commented 7 years ago

Currently Bootstrap depends on jQuery and it will be the case until we ship a new major release (v5). But we already talked about that with @mdo to separate Bootstrap in different packages with Lerna, maybe that's something we can work on a beta 2 ?

bardiharborow commented 7 years ago

I don't see any issue with switching jquery and popper.js to be peerDependencies instead, as long as we tweak the docs to remind people to include them separately if they want to use our JavaScript.

XhmikosR commented 7 years ago

Yup, agreed with @bardiharborow. 👍

klimov-paul commented 7 years ago

From our homepage, we say HTML, CSS, and JS framework.

For me such statement is not exacly correct. Term 'framework' usually used regardless libraries, which provide basic scaffolding for the actual solution composition. Speaking about Bootstrap related JS, the only 'framework' would be JQuery itself, while all Bootstrap JS code is just a set of JQuery plugins, just as JQuery UI is. This is debatable of course, but I think many developers sees it in this way.

Back in Bootstrap for Yii2 we do not include JS part unless some particular JS component is used:

https://github.com/yiisoft/yii2-bootstrap/blob/master/BootstrapAsset.php#L18-L24 https://github.com/yiisoft/yii2-bootstrap/blob/master/BootstrapPluginAsset.php#L18_L28

this is a breaking change, so we have to decide now or wait until v5

I understand that current development of v4 has already come too far to be rewritten without JQuery - I do ask for this. All I wish the mandatory dependency to be removed, so if developer chooses to use other JS framework he do not need to pull jquery files from Bower/NPM.

I don't see any issue with switching jquery and popper.js to be peerDependencies instead, as long as we tweak the docs to remind people to include them separately if they want to use our JavaScript.

Yes, this would be fine.

Johann-S commented 7 years ago

We will have a conflict here, because a lot of users want a release of Bootstrap bundled with Popper.js (see : https://github.com/twbs/bootstrap/issues/22783) and that's what I done on this PR https://github.com/twbs/bootstrap/pull/22888

bardiharborow commented 7 years ago

@Johann-S this is about npm dependencies, and allowing downstream users to load our CSS without pulling all our JS dependencies. This doesn't stop us generating a Bootstrap + Popper.js bundle.

@XhmikosR The only concern I have is how does this affect our webpack strategy? I don't use webpack myself, so I'm really not sure how it all works.

Johann-S commented 7 years ago

I don't think it will change our webpack strategy here, user have to install jQuery and Popper.js packages if they want to use our JavaSript

XhmikosR commented 7 years ago

Yeah, I think it shouldn't change anything; the user will still have to install jQuery and popper.js. That being said I don't use webpack myself...

pkozlowski-opensource commented 7 years ago

How about creating a separate package (ex. bootstrap-css) that would contain only CSS part and have the existing package to depend on bootstrap-css?

This would give CSS-only people a streamlined package and keep the existing behaviour as-is.

mdo commented 7 years ago

For me such statement is not exacly correct.

My point wasn't in us being a framework, toolkit, or whatever other name you want. We're a project with HTML, CSS, and JS—it's all or nothing right now. As mentioned, we have talked about having something split up our mono-repo into a series of other repos so folks can easily include one or more without the bulk of the entire project.

Keeping 'jquery' as mandatory dependency looks unprofessional.

I don't see how having a dependency looks unprofessional. You don't need jQuery; that we do isn't not unprofessional. It's simply irrelevant to you.

Ideally JS related code should be moved into a separated repository, which will depend on 'twbs/bootstrap' and 'jquery', while 'twbs/bootstrap' itself will be requirement free.

This won't happen for a long time to come.


All that said, I'm going to stub out a PR that removes the dependencies and updates some docs to better illustrate how our code works. I imagine this will be the final potentially breaking change for us before we can launch the beta.

Also, see the new v4.3 project. It'll be a release solely geared towards integrating Lerna or something like it. Would love some thoughts if y'all have any.

dkrutsko commented 7 years ago

The jQuery debate aside, even though it's part of the dependencies, I don't see how it affects people. My company uses Bootstrap through NPM and only imports the CSS required. The jQuery and JS components are never used. But I guess people are concerned about having it in their node_modules folder? Perhaps the peerDependency suggestion by @bardiharborow would be a good compromise. Or perhaps splitting the packages as suggested by @pkozlowski-opensource.

I'm thinking that unless the JS components are rewritten in VanillaJS, there might be no need to change anything. For version 5, the only suggestion I would make is to revisit some of these JS components and see if they could be implemented through CSS instead. A lot of cool effects can be achieved through a little markup and some checkboxes/radioboxes. But I'm sure this has already been suggested many times in the past.

Either way, I wish you luck in finding a good solution!

mdo commented 7 years ago

Opened #23244. Please jump in with reviews and any feedback.

Johann-S commented 7 years ago

About Lerna that's a very good things. IMO a good a beginning should be to have two packages : bootstrap-css and bootstrap-js after that we can create a package for each JS plugins so we will have something like that :

And they are the whole pack as currently bootstrap . +-- bootstrap-css +-- bootstrap-js | +-- bootstrap-tooltip | +-- bootstrap-util | +-- bootstrap-carousel | +-- bootstrap-tooltip Etc...

klimov-paul commented 7 years ago

I don't see how having a dependency looks unprofessional. You don't need jQuery; that we do isn't not unprofessional. It's simply irrelevant to you.

The days of jQuery are passing: the common demand for the modern web application is to be 'one-page-site'. This is the demand of the business - it is not I who speaks it. jQuery is not suitable for 'one-page-site' project creation - this task is resolved by modern JS frameworks like AngularJS, RactJS, EmberJS and so on.

You an of course stay with the old technology as it is a part of your zone of confort - that is fine and natural for the human. However, the time is passing and more and more developers will have to abandon JQuery usage and move to 'one-page-site' solutions. It will take another several years to prepare Bootstrap 5.0, do they need to wait until then and struggling with JQuery installation?

At the present state, intalling Bootstrap via Bower, I need to waste time, network resources and disk space to fetch the JS libraries, which I do NOT need. This contradicts the idea of package intallation and package managers like Bower/NPM. If I need additional functionality - I should install additional package.

btecu commented 7 years ago

Great idea @klimov-paul. Would you be interested in taking a stab at it?

alanondra commented 7 years ago

The days of jQuery are passing: the common demand for the modern web application is to be 'one-page-site'.

These may be the demands of a fair few non-IT people with developers in their staff, but this is not necessarily the demand of all web application developers, nor is it necessarily the right one. Single-page applications do well for certain things, but are inadequate for others.

Yes, you may technically do many things with a single-page application that are traditionally done with multi-page, but it's not always going to be the most stable and trustworthy, and will by definition be the least accessible since it depends on a technology that can totally break UX via different implementations in various clients, and different environmental factors. I understand the appeal to fledgling developers to offload much of the workload to the client side, but having survived the browser wars, it's misguided to believe it's a solution to fit all projects.

On-topic: I second the request that it not necessarily depend on jQuery. I think it should still be discussed as a current feature since v4 is still in the alpha stages, but understand if workload is prohibitive for a change in v4.

XhmikosR commented 7 years ago

It's in our TODO list with @Johann-S for the next major version. But let's not jump ahead, one step at a time. Unless someone wants to make a branch for this and we can all work together on it.

JavanXD commented 7 years ago

@klimov-paul ng-bootstrap and ngx-bootstrap is indeed working with one-page-applications. There is no conflict using Bootstrap4-beta in Angular4. Bootstrap4 is not, as you said, out of date as framework for modern web technologies.

klimov-paul commented 7 years ago

ng-bootstrap and ngx-bootstrap is indeed working with one-page-applications.

This is exactly what I am talking about: solutions based on Bootstrap CSSS should NOT mandatory bound to jQuery. ng-bootstrap is only one of the countless solutions, where developers replacing JQuery with other JS framework.

klimov-paul commented 7 years ago

Bootstrap4 is not, as you said, out of date as framework for modern web technologies.

I have not said such thing. I was saying that mandatory usage of jQuery is an outdated practice and it is you who prove me right. It is @mdo's point that Bootstrap 4 is a whole solid frontend framework, where CSS and JS parts are bound together and are not meant ot be used separately. Maybe you should pass this statement to the ng-bootstrap team saying that using Bootstrap CSS without JQuery is actually incorrect and they should use both AngularJS and JQuery (loading both heavy libraries at page load) in thier project?

The Bootstrap team is doing well ignoring such projects as ng-bootstrap, pretending that problem of usage Bootstrap CSS without JQuery, but under different JS framework, simply does not exist.

The modern front-end complex solution as Bootstrap is should be more flexible in this matter. It MAY provide some default JS layer (which may be built even on top of JQuery), but should make it flexible enough to be replaced. It is sad that this will not be changed at Bootstrap v4 and should wait untill v5, as the problem itself will become more and more annoying with the passing time, while it will take several years to release new major version.

Johann-S commented 7 years ago

Things can move quickly @klimov-paul 😉 and if you don't think so you should follow the evolution of Bootstrap

mdo commented 7 years ago

I'm not sure why this discussion is ongoing. We get it—jQuery is old and not needed in your projects. It's still a helpful tool for us and millions of others. We've already said it, but I'll say it again—we'll work on moving to vanilla JS as we can.

If you want this so badly now, please help! We're a small team working on this stuff whenever we can while having full-time jobs elsewhere. If you believe jQuery to be so outdated, help @Johann-S and our team rewrite the plugins to drop it completely.