laravel / ideas

Issues board used for Laravel internals discussions.
939 stars 28 forks source link

Laravel spark #1105

Closed pjebs closed 5 years ago

pjebs commented 6 years ago

As front development is moving away from jquery, is it possible to remove jquery dependency from Laravel Spark?

I understand for registration and profile page it's forced upon you. I'm fine with jquery and Vue being force upon me. That was stated from the get go.

But the documentation says you can still do the "bulk" of your application in the javascript framework of your choice. However, it then says that jquery will still be applied.

How can I disable jquery from the "bulk" of my application. If not possible, then this is a feature request.

The main reason is because I use react.js and materializecss instead of bootstrap. (@taylorotwell If you look at materialize, you'll probably change over too).

The latest version of materializecss removed their dependency on jquery.

steveheinsch commented 6 years ago

I believe they will stick with jQuery as long as they are using Bootstrap, which as you know, is very widely used and uses jQuery. Materializecss looks cool, but it's still in beta. Something like that would also have to be in a new major version since it would break just about every existing app using spark. They waited to release Spark v6 until bootstrap 4 was out of beta. It's too bad bootstrap 4 still uses jquery. It would be nice if it was pure vanilla js and used css animations.

pjebs commented 6 years ago

I'm actually referring to the part outside the "profile" and "registration" page. The documentation states that we can use whatever javascript and css framework we want for the the rest of our site.

...But the documentation also states, that they still load 'jquery' for what appears to not be an absolute necessity (for pages outside of profile and registration).

steveheinsch commented 6 years ago

jQuery is used in the internal spark js and not just on those 2 pages. It also uses lodash, underscore, axios, moment and a few other js packages (some of which the functionality is already covered by jQuery). All they mean is you don't have to use jQuery for the rest of your app if you don't want to, but it still relies on it internally. Like the rest of my app uses Vue and vanilla js and no jQuery (except for what Spark uses internally)

pjebs commented 6 years ago

Thanks for the info. In that case it's a "feature request"

rocketlaunchr-cto commented 5 years ago

@steveheinsch

Laravel Spark says this in the docs:

If your application exposes an API, it can be beneficial to consume that API yourself from your application's front-end JavaScript code. This allows you to share the same API between your application and your API SDKs you may be shipping on various package managers.

Spark makes it entirely painless to consume your API in this way. Simply make requests to your API routes using your JavaScript framework as normal. You do not need to pass any token or credentials. All of the authentication will be handled automatically by Spark, which generates "transient", short-lived API tokens behind the scenes automatically when users load your application's pages. These API tokens are automatically refreshed in the background by Spark.

I'm trying to use that feature with a "react" front-end (which they advise against). But calling token protected API's but the Spark frontend would be very nice.