I'm old school, so I downloaded the source code to 1.12.0 and then did the following:
<script src="/popper.js-1.12.0/dist/popper.js"></script> <script src="/bootstrap-4.0.0-beta/dist/js/bootstrap.js"></script>
But I'm getting:
Uncaught SyntaxError: Unexpected token export
on line 2294
where it says:
export default Popper;
However, Bootstrap 4 can be used without Popper. js, if we don't use tooltips, popovers nor dropdowns. For example, navbar's JS functionality (mobile menu on the right) works well without Popper. js.
Bootstrap depends on Popper, which is specified in the peerDependencies property. This means that you will have to make sure to add both of them to your package.
Bootstrap has dependency on Jquery and Popper js.
You want to use the dist target specified in the package.json
file as main
entry.
In this case, you are looking for the umd
build (dist/umd/popper.js
)
The UMD pattern typically attempts to offer compatibility with the most popular script loaders of the day (e.g RequireJS amongst others). In many cases it uses AMD as a base, with special-casing added to handle CommonJS compatibility.
This means that an UMD bundle can be loaded via <script>
tag and get injected inside the global scope (window
), but also work if required with a CommonJS loader such as RequireJS.
Either of these CDN versions will work:
https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.5/umd/popper.js https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.5/umd/popper.min.js
Other answers/comments mention the version, however the problem is not related to versioning.
It's never a bad practice to use Bootstrap's example of including popper because it should always work. Bootstrap 4 as of now recommends popper 1.11 which is a safe choice, however version 1.12.5 should work fine as well.
Side note: Why the confusion with umd, esm, and plain ol' popper files? The intention is flexible module packaging, but in reality it could be made simpler. This post explains some of the issues with new module types.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With