1

Our site has been getting these recurring errors which I cannot track down and just needed some guidance. Each error revolves around jQuery and Bootstrap 4.6 methods as not a function. Here's what I've done so far:

  1. Made sure jQuery is loaded first and all other scripts are dependent on jQuery
  2. Made sure all of our jQuery-dependent scripts are loaded in the footer (our site loads jQuery in the header...is this correct?)
  3. Tried calling methods in the following ways:
// One
jQuery('#example-modal').modal('show');


//Two
$('#example-modal').modal('show');


// Three
jQuery(($) => { $('#example-modal').modal('show') });

Here is how we're loading the scripts:

// Popper
wp_enqueue_script( 'popper-js', get_template_directory_uri() . '/assets/js/popper.min.js', array( 'jquery' ), $version, true );

// Bootstrap (in footer??)
wp_enqueue_script( 'bootstrap-js', get_template_directory_uri() . '/assets/js/bootstrap.min.js', array( 'jquery', 'popper-js' ), $version, true );

// Theme
wp_enqueue_script( 'theme-js', get_template_directory_uri() . '/assets/js/theme.bundled.js', array( 'jquery', 'bootstrap-js' ), $version, true );

These methods work for me all the time on a mac with FireFox, but I'm still getting them in Sentry. I've noticed the vast majority (96%) is on Windows >= 10.

Here are some some links to the error:

Error 1 Error 2 Error 3

For more context, I write JS in almost exclusively vanilla JS until I need a Bootstrap method. Am I missing something? This is driving me a little crazy.

1
  • .modal(), .tooltip() and .tab() must be getting called by your JS before the files that set them up are called. Make sure that your JS that uses these functions is called last. Commented Jun 28, 2024 at 19:39

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.