最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Bootstrap, jQuery, Popper, and CSS load order - Stack Overflow

programmeradmin0浏览0评论

I'm not sure my load order is correct. Can someone make sure it is?

In "head" :

<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="css/style.css">

In "body" :

<script src="js/bootstrap.js"</script>
<script src="js/jquery-3.2.1.min.js"</script>
<script src="js/jquery-slim.min.js"</script>
<script src="js/popper.min.js"</script>
<script src="js/custom.js"></script>

I'm not sure my load order is correct. Can someone make sure it is?

In "head" :

<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="css/style.css">

In "body" :

<script src="js/bootstrap.js"</script>
<script src="js/jquery-3.2.1.min.js"</script>
<script src="js/jquery-slim.min.js"</script>
<script src="js/popper.min.js"</script>
<script src="js/custom.js"></script>
Share Improve this question edited Nov 19, 2017 at 2:39 Neil 14.3k3 gold badges35 silver badges53 bronze badges asked Nov 19, 2017 at 2:30 TomahawkTomahawk 311 silver badge3 bronze badges 4
  • 1 For your js scripts, jquery should be first since bootstrap depends on jquery – JJJ Commented Nov 19, 2017 at 2:40
  • CSS is okay. JS: 1) jQuery 3.2.1.min.js 2) bootstrap.js 3) popper.min.js 4) custom.js --- Just TRASH jquery-slim.min.js since it is another version of jQuery, but without Ajax and animations (reference here), so it's already loaded... Don't load it twice. – Louys Patrice Bessette Commented Nov 19, 2017 at 2:48
  • See the Docs BootstrapJS is reliant on jQuery and PopperJS (they need to be placed prior to BootstrapJS). See the Starter Template for an example. – vanburen Commented Nov 19, 2017 at 4:43
  • 1 Possible duplicate of script order for jquery with bootstrap – adiga Commented Nov 19, 2017 at 8:54
Add a ment  | 

2 Answers 2

Reset to default 5

In "head" :

<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/style.css">

In "body" :

<script src="js/jquery-3.2.1.min.js"></script>
<script src="js/popper.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/custom.min.js"></script>

Try using the minified version they are much smaller therfore much faster to load

Check this out !

In head :

<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn./bootstrap/4.0.0-beta.2/css/bootstrap.min.css" crossorigin="anonymous">
<!-- CUSTOME STYLE CSS-->
<link href="https://fonts.googleapis./css?family=Roboto" rel="stylesheet">
<link rel="stylesheet" href="style.css">

In Body :

<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery./jquery-3.2.1.slim.min.js" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare./ajax/libs/popper.js/1.12.3/umd/popper.min.js" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn./bootstrap/4.0.0-beta.2/js/bootstrap.min.js" crossorigin="anonymous"></script>
发布评论

评论列表(0)

  1. 暂无评论