Yii Framework Forum

How do we use jQuery and bootstrap and their alternatives in Yii 3?

(Alexander Makarov) #21

Isn’t Webpack out of trends already?

(Knight Yoshi) #22

Definitely not!

5.7M weekly downloads

(Jacob Moen) #23

I don’t want to deal with webpack since I am already using Gulp. Yes, and even Bower! I simply do not have the time nor the patience to stay in the JS loop.
I hope it doesn’t become a requirement. :wink:

(Knight Yoshi) #24

If you read, I said they would also ship an already bundled version, just like how they do now. Webpack would be for people, like myself, that want to have finer control over the JavaScript build.

(Jacob Moen) #25

I am already handling all assets myself, JS build and CSS, etc. So, instead of assuming Webpack, I would like being able to either carry on with whatever I’m doing or - even better! plug in whatever I am using (Gulp and friends) as an alternative to webpack (which I, sorry to say, am not very fond of).

(Knight Yoshi) #26

I’ve used Gulp. It’s just a task runner, not a bundler like Webpack. In fact, there’s a Node module that allows you to use Webpack in a Gulp task. Fundamentally they serve two different purposes, and Gulp doesn’t have the functionality that Webpack. You can mix and match different things to achieve something similar, but they’re two different tools for different purposes.

Also for anyone that’s curious, this is the module I’m talking about that allows you to use Webpack in Gulp

(Jacob Moen) #27

I know what it is. And I totally do not need it at all :smile:
It’s got terrible documentation and there is a lot of overlap between Gulp and it.
I do acknowledge that you might need a bundler. Mainly when you are developing complex Node/JS applications. Definitely not when you are developing a PHP application with a couple of scripts. :stuck_out_tongue:

(Knight Yoshi) #28

But Yii doesn’t have exclusively PHP. It has JavaScript as well. It should provide more functionality to be able to allow the developers to have control over how the JavaScript is deployed to the browser; i.e. in my own JS files with only the components necessary for minimum file size.

The developer is more capable of determining what is needed for the project/page and can optimize for that necessity. Your personal preference shouldn’t exclude the overall benefit that Webpack and the like can provide for people that want to use it. You’re saying, “I don’t like it, that’s why it shouldn’t be included.” That’s not a very good argument.

(Jacob Moen) #29

It is a very good argument, actually :wink:
What I mean is: I would like this to be wholly voluntary and not a requirement.
I am already exercising full control of my assets, without the help of Yii.

That said, I am glad to see that there is work being done to decouple Yii from jQuery and Bootstrap. I am currently using Bootstrap4, which means I had to remove Gii and Debug from my project (because they depend on Bootstrap)

(Knight Yoshi) #30

It’s not, because Yii isn’t specific to your project. It’s for everyone that wants to use it, so it should accommodate for different needs.
Your argument is valid for your projects, not collectively for people who have different needs.

Again, I said it should be optional. They can include a bundled version of their JS. In fact, doing it this way they can work with the same source as others and it would make it easier to maintain for the contributors/collaborators, then just bundle it and ship it. No Webpack necessary for people who don’t want it.

(Jacob Moen) #31

I just fail to see the relevancy of having webpack anywhere near Yii in the first place.
But as long as it is non-intrusively optional, I don’t really have a beef with it.

(Knight Yoshi) #32

You might as well say you fail to see the relevancy of JavaScript in the PHP framework, then.
I’ve pointed out a possible use with the JS validation as an example, being able to only bundle just what the developer needs instead of loading all of the Yii JS from a single file to do that one thing. It’s more performant to only have what you need. It cuts down on load time as well as processing overhead.

(Jacob Moen) #33

If your application is fairly small, and you don’t have many static assets and you only need to build one Javascript file to serve to the client, then Webpack might be more overhead than you need.

From Webpack: When To Use And Why

(Knight Yoshi) #34

Yeah. And? You can’t determine how large another person’s project is.
Again, optional, but provided functionality.

(Jacob Moen) #35

Excuse me, dear @Knight_Yoshi, you seem to have a reading problem?

(Knight Yoshi) #36

Well clearly you do “have a beef with it” you keep arguing against it.

(Fsb) #37

What is now trendy

(Alexander Makarov) #38

You won’t have to remove these tools from the project very soon. See what happens in Yii 2 versions of these :wink:

(Alexander Makarov) #39

I’ve heard that next thing will be either https://rollupjs.org/ or https://parceljs.org/.

(Alexander Makarov) #40

Overall core team can’t really keep up with all these changes and trends in JavaScript world and, because of that, either we’ll drop JavaScript part of Yii as much as possible or we need to find someone who’s into it and can maintain these parts.