1

I have a create-react-app project with many components and they import jquery using ES6 modules as below.

import $ from 'jquery'

The current build time is about 8 minutes and I feel it's because of jquery.

Did anyone face this before? If so what is the best way to use jquery in create-react-app

1 Answers1

0

Using jquery in react apps is undesirable because react is declarative and jquery is 100% imperative. It makes code less maintainable and readable. Also it makes hard to test your components. If you use jquery for ajax you can replace it for example with axios.

ivankoleda
  • 340
  • 1
  • 11
  • We are not using this for ajax requests. We use it for few jquery helpers. Eventually we want to move away from jquery but it is a huge change for us as it is used in all the components. So we want to know the best way to import it. – Krishna Chaitanya Oct 25 '18 at 06:59
  • While true, this is all completely irrelevant to the OP's issue of loading times. – Rory McCrossan Oct 25 '18 at 07:02
  • @KrishnaChaitanya check this one https://stackoverflow.com/questions/34338411/how-to-import-jquery-using-es6-syntax – ivankoleda Oct 25 '18 at 07:07