0

I have included two bootstrap links in my HTML page. This is causing issues with the accoridan I have included. The accordian once opened wont collapse when clicked again.

I have figured out that this is because of the two bootstrap links and the problem is solved when I remove one. Does anyone know why this is occurring and how to solve this?

The two bootstrap links are a local copy and a CDN copy. I use the CDN primarily and have a local backup incase the CDN is down.

Any help is appreciated.

John D.
  • 11
  • 4
  • 1
    Why and how are you including Bootstrap twice? The local copy should only be included if the CDN isn't able to be loaded. Please post a [mcve] so we can see what you're doing. – j08691 May 04 '17 at 01:46

1 Answers1

0

Unfortunately, Bootstrap doesn't provide a specific variable for the fallback purpose. However, you can still achieve the CDN fallback behavior, you can test for one of the bootstrap plugins. For example, you can check for the modal plugin like below-

<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script>$.fn.modal || document.write('<script src="/js/bootstrap.min.js"><\x3C/script>')</script>

This will only load the local version of the bootstrap.min.js file if the CDN doesn't work.

Please note that this might fail in future if the modal plugin gets renamed or removed in future.

Shekhar Chikara
  • 3,786
  • 2
  • 29
  • 52