Popper v Bootstrap gotcha
- By : Matthew Brown
- Category : WordPress Development
- Tags: Bootstrap, PHP, Popper, WordPress
I encountered a bit of a gotcha while working with Bootstrap and Popper recently.
Although both javascript libraries were enqued, when I checked the consol I saw this:
Uncaught TypeError: Bootstrap's tooltips require Popper.js
It turns out that the order of enqueuing matters.
This works
<?php
//...
wp_enqueue_script( 'popper-js' );
wp_enqueue_script( 'bootstrap-js' );
This does not
<?php
//...
wp_enqueue_script( 'bootstrap-js' );
wp_enqueue_script( 'popper-js' );
The difference is that popper-js must happen before bootstrap. If not, then bootstrap gets the right hump.
Not the easiest error to track down. Anyway, I hope this post will save someone from a lot of head scratching. Meanwhile, back to the grindstone for me.
No Comments