1

I am trying to install smoothState.js to my wordpress theme. It is not working and while debugging, I am seeing this error - "jQuery is not defined". This is in the smoothState.js file I copied over.

Can anyone help me with this? Am I am installing the file incorrectly? I tried adding a (jQuery) note after the function and it's still not working. Appreciate the help! The error is for this particular function below

/*!
 * smoothState.js is jQuery plugin that progressively enhances
 * page loads to behave more like a single-page application.
 *
 * @author  Miguel Ángel Pérez   reachme@miguel-perez.com
 * @see     http://smoothstate.com
 *
 */

(function (factory) {
  'use strict';

  if(typeof module === 'object' && typeof module.exports === 'object') {
    factory(require('jquery'), window, document);
  } else {
    factory(jQuery, window, document);
  }
bugbytes
  • 315
  • 1
  • 5
  • 13

1 Answers1

1

It looks like smoothState.js is loaded before jQuery is ready.

How are you adding smoothState to your page? Using wp_enqueue_script?

Also, how is smoothState loaded in JS?

This link might help you https://webdesign.tutsplus.com/tutorials/how-to-integrate-smoothstatejs-into-a-wordpress-theme--cms-26610

remborg
  • 528
  • 3
  • 14
  • Yes. Enqueued it in script. Do I have to install jQuery? from my understanding, Wordpress already has jQuery. – bugbytes Dec 21 '20 at 08:58