1

I have included a bootswatch theme in my website.

<!-- Bootstrap CSS served from a CDN -->
<link href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.7/cerulean/bootstrap.min.css" rel="stylesheet" integrity="sha384-zF4BRsG/fLiTGfR9QL82DrilZxrwgY/+du4p/c7J72zZj+FLYq4zY00RylP9ZjiT" crossorigin="anonymous">

<!-- Scripts -->
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

The problem is that bootstrap.min.css file loads twice. I can see it twice in resources when I open developer console on any browser. It is the same file because I can see that it is loaded by the same html line. Because of this, when I want to close a collapse or a menu, it just closes and opens again fast. I have no idea why it loads twice. How can I fix this?

3
  • @neophyte I am using Laravel for developing this website. It might be that it already has bootstrap included and I included it once again in my website layout. Feb 12, 2017 at 11:23
  • @neophyte I am confused because this file gets loaded by the same line of HTML. Feb 12, 2017 at 11:38
  • It could be your laravel. I couldn't understand what do you mean by getting loaded with the same line. Can you post a image of only that portion of console log.
    – neophyte
    Feb 13, 2017 at 0:55

2 Answers 2

0

I can think about two reason for your issue---

No.1

You have a plugin that uses bootstrap and it is loading the additional cdn.

No.2

You are adding some include file in your page which have the bootstrap cdn inside it. Hence your main page loads two bootstrap cdn.

Suggestion Try removing bootstrap cdns from the bootswatch theme. As I am assuming that your website has already bootstrap cdn included in it.

1
  • When I go to developer tools in google chrome I can see all the files loaded by the page in Network tab. I can see that this file was downloaded two times there. In the same tab I can see what line from my html downloaded this file (when I hover over Initiator) and it is the same line that downloads this file, like it would be declared two times in my HTML, but it is declared only once. Feb 15, 2017 at 17:17
0

I know it's a old thread, but I was searching for the same and also found the answer.

Remove integrity attribute from the url and it downloads only once.

This new attribute integrity attribute which I think is what makes the browser to call the cdn the first time to check that the file is not manipulated and then the second call happens to load the file.

Somehow it is flawed and should not download twice.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.