1
votes

I am working on an old project which uses Ember CLI 1.13.12 where every file (including app.js/controllers/routes/components) has the following import at the top

import $ from 'jquery';

I removed the above line from all the files and still the app is running perfectly with all jquery code ( using $() or this.$()).

I tried to find if jquery is enabled in any config file but I couldn't. Also, there is no optional-features.json file in the project where jquery-integration can be set to true.

So, is it necessary to import jquery in an Ember CLI 1.13 project?

Can we disable the default jquery in Ember CLI 1.13?

I am new to Ember and that too to an old version so finding it difficult to understand.

2

2 Answers

2
votes

So, is it necessary to import jquery in an Ember CLI 1.13 project?

No. It's actually never necessary, but recommended. This makes it much easier to see where jQuery is can be very helpful when transisioning away from jQuery.

Can we disable the default jquery in Ember CLI 1.13?

Not really, no. Back then ember itself required jQuery.

2
votes

Ember was bundled with jQuery at that point, which is why this.$() would work without the need to import it.

Using $ as a global variable is probably a bad idea. Avoid global variables as much as possible. If you do use global variables, at least write them like the following so it's clear it comes from the window scope.

const { jQuery: $ } = window;