omrakhur omrakhur - 2 months ago 6x
Javascript Question

Is the order of these JS scripts correct?

These scripts won't load on first page load, but when I hit refresh they load up correctly. This is the latest version of Chrome with all extensions disabled.

<script src="/lib/bootstrap-select/dist/js/bootstrap-select.min.js"></script>
<script src="/lib/select2/select2.min.js"></script>

<script src="/lib/jquery.maskedinput/dist/jquery.maskedinput.min.js"></script>
<script src="/lib/moment/moment.js"></script>

<script src="/lib/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js"></script>
<script src="/lib/twitter-bootstrap-wizard/jquery.bootstrap.wizard.min.js"></script>

<script src="/lib/jquery-autosize/dist/autosize.min.js"></script>
<script src="/lib/bootstrap3-wysihtml5-bower/dist/bootstrap3-wysihtml5.all.min.js"></script>

<script src="/lib/fullcalendar/dist/fullcalendar.min.js"></script>
<script src="/lib/jquery-ui/ui/core.js"></script>

<script src="/lib/jquery-ui/ui/widget.js"></script>
<script src="/lib/jquery-ui/ui/mouse.js"></script>

<script src="/lib/jquery-ui/ui/draggable.js"></script>

<!-- page application js -->
<script src="/js/forms-wizard.js"></script>
<script src="/bower_components/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js"></script>
<script src="/js/component-calendar.js"></script>

pid pid

In Chrome press F12 and click console. This is the error log.

Any error (such as loading a *.js file with broken references to another *.js file) will be shown here.

You can also print to this log with console.log("hello"); and somesuch.

If there are no errors during the page load everything is in order. Otherwise, it will tell you in which file a reference is broken.

Move the file with the error below one step and then press F5 to refresh the page. A new reference error may appear. Continue moving those files below until it loads correctly.

If you can make out more from the error (such as autosize does not exist) you may gain insight in which file is referenced (the one defining autosize in this example) and so fix the order faster than just moving files up/down.