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 [email protected]
* @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);
}
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