-3

Update

Thank you Chris and Taplar for providing the following links -

www.getbootstrap.com/docs/4.5/getting-started/introduction
load and execute order of scripts

I did not look at the documentation in the first place because I did not have enough grasp of the issue, to even know what part of the documentation to search in.

Original Question

I had many issues when adding my date widget to my customer user profile model, you can see more of my code relating to the issue here. One issue was related to the order of my Java Scripts.

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
 
 <script src="https://cdnjs.cloudflare.com/ajax/libs/tempusdominus-bootstrap-4/5.1.2/js/tempusdominus-bootstrap-4.min.js" integrity="sha256-z0oKYg6xiLq3yJGsp/LsY9XykbweQlHl42jHv2XTBz4=" crossorigin="anonymous"></script>

If I put my scripts the other way round, the date widget would not work.

It never dawned on me that the order the scripts were in would have an impact on whether the code worked or not.

Would an experienced Python programmer be able to tell, just by looking at the two scripts, what order they need to be in?

To prevent future problems, is there anything I can check, to work out what orders script need to be written in?

Ross Symonds
  • 404
  • 3
  • 15
  • 3
    Bootstrap requires jquery so jquery need to be executed first. You cannot use variables before declaration in every language. I don't know python is related here. – Konrad Linkowski Aug 20 '20 at 17:00
  • 3
    This has nothing to do with Python or Django. JavaScript code is evaluated in the browser, and in the order in which it's included. If a script has a dependency on another script, then it needs to come after that other script. – David Aug 20 '20 at 17:00
  • 3
    You can work out the order by reading the library's documentation. – Guy Incognito Aug 20 '20 at 17:01
  • 5
    ↑ https://getbootstrap.com/docs/4.5/getting-started/introduction/ – Taplar Aug 20 '20 at 17:02
  • 3
    Does this answer your question? [load and execute order of scripts](https://stackoverflow.com/questions/8996852/load-and-execute-order-of-scripts) – Chris Aug 20 '20 at 17:02
  • 2
    David I encountered the problem while using Django which is why I added the Python and Django tags, I have now removed these. – Ross Symonds Aug 20 '20 at 17:08
  • 2
    Thank you Taplar and Chris for providing links. I have read the links and now have a better grasp on the issue. – Ross Symonds Aug 20 '20 at 17:09
  • 1
    Hey Ross Would you mind sharing some of the code behind your date widget? Were you using the date widget for DOB or something else? – Vendor EagleLimited Aug 20 '20 at 22:07
  • I have talked about my date widget here - https://stackoverflow.com/questions/63347615/getting-date-widget-to-display-american-dates-for-american-users/63348193?noredirect=1#comment112026150_63348193 – Ross Symonds Aug 20 '20 at 22:09
  • I was making a customer user registration model and wanted to include a DOB field. – Ross Symonds Aug 20 '20 at 22:10

1 Answers1

5

The libraries must be included in that order, as the bootstrap file is a plugin for the base library of jQuery. Without the base library already included, the addon has nothing that it can add-on to.

Taplar
  • 24,246
  • 4
  • 18
  • 33