question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to prevent laravel-mix to include the full jQuery Library

See original GitHub issue

I basically used a .js file that I created in a Laravel 5.1 Project and that was now upgrade to Laravel 5.4. In Laravel 5.1 we had elixer and the file was compress as expected.

Now with laravel-mix the fill is also compress and put into public/js/ but the file is much larger because the hole jQuery Library is included.

I want to load jQuery seperate e.g. from a CDN!

mix.js('resources/assets/js/foo.js', 'public/js')

With this lines you can test it:

// resources/assets/js/foo.js
$(document).ready(function(){
    $('#foo').removeStyle('bar');
});

this is also do the same (including jQuery):

// resources/assets/js/foo.js
+function ($) {
    $(document).ready(function(){
        $('#foo').removeStyle('bar');
    });
}(jQuery);

laravel-mix: v0.8.1 Node.js: v6.9.5 (latest LTS) yarn: v0.20.3

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

8reactions
QWp6tcommented, Feb 19, 2017
0reactions
stefanpolzercommented, Feb 19, 2017

@QWp6t I do not have any bootstrap.js with the window.$ = window.jQuery = require('jquery'); But mix.autoload({}); in the webpack.mix.js file do the trick for me …

Would be nice if this finds his way int the Laravel Docs

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to prevent laravel-mix to include the full jQuery Library
This snippet specifies that Webpack should prepend var $ = require('jquery') to every location that it encounters either the global $ identifier ...
Read more >
Exclude jQuery from Laravel.mix - Laracasts
I'm building a project without the need for jQuery (I'm solving everything with Vue), however the Laravel.mix requires me to add the jquery...
Read more >
Laravel Mix always include jQuery - Stack Overflow
I use Laravel 5.6, with Mix. I want to load a plugin which uses jQuery to my project. I created a fileuploader.js file...
Read more >
Laravel Mix - Laravel - The PHP Framework For Web Artisans
Laravel Mix, a package developed by Laracasts creator Jeffrey Way, provides a fluent API for defining webpack build steps for your Laravel application...
Read more >
Laravel Mix Options
extractVueStyles: Extract . · globalVueStyles: Indicate a file to include in every component styles. · processCssUrls: Process/optimize relative stylesheet url()' ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found