vchan
vchan

Reputation: 860

Correct loading order jQuery, Bootstrap and select2 .js files

I would like to ask if there is a specific loading order in your web pages that should be used for the jQuery, Bootstrap and Select2 JavaScript files in order to avoid any potential errors and if there should be one what would be the most appropriate one.

Upvotes: 2

Views: 2091

Answers (1)

Master Yoda
Master Yoda

Reputation: 4412

You will always need to load jQuery before bootstrap or any other plugins that rely on it.

I like to order my links/references as JavaScript first, css second and ensure that each reference is ordered by their respective plugin but thats just my own personal preference.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/js/select2.min.js"></script>

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/css/select2.min.css" rel="stylesheet"/>

Upvotes: 1

Related Questions