You can replace the ancient version of jQuery included with meteor by default

All projects have a quite gigantic payload of backward compatible jQuery.
To switch to jQuery 3.0 reference the CDN version in your head tag:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>

At this point you now have 2 versions of jQuery, which is even worse. You need to replace the built in jQuery payload with a stub because other packages have jQuery as a dependency and they don’t acknowledge the jQuery in the head tag:

  1. Create a folder in your project directory called packages. If you use local packages (you should if you haven’t adopted the modules system yet) then you’ll already have this folder.

  2. Create a dir named jquery and place a file named package.js in it and paste in the follwing contents:

    Package.describe({name:‘jquery’, version:‘1.11.9’});
    Boom, you’ve just removed 100 KB+ off your payload.

5 Likes

You can just install jQuery with NPM. The meteor jQuery package first tries to load jQuery from your node_modules folder. Only if it’s not found does it then load 1.11.2.

From the MDG jQuery package’s main.js file:

try {
  var jQuery = require("jquery");
} catch (e) {
  jQuery = require("./jquery.js");
}

Thanks that’s probably a better solution. Also for users looking to use the CDN version they can theoretically use the node_modules folder instead of the packages folder

I don’t think this is still the case. Using the bundle visualizer I can see that both versions of jQuery are bundled up; one under meteor and the other under node_modules.

1 Like