I need to check if bootstrap-5 JavaScript file is loaded. There is a simple way of doing it using jQuery. For example, a common asp-fallback test expression for using Bootstrap JavaScript file from CDN is as follows:
asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal"
Since older versions of Bootstrap JavaScript files relied on jQuery for their own operation, the above test worked well. However, Bootstrap 5 is designed to be used without jQuery, so a test that relies on window.jQuery is no longer appropriate.
What is a minimal expression that returns a truthy value only when one of the Bootstrap-5 JavaScript files is loaded?
You can check window.bootstrap to verify Bootstrap 5 is loaded.
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