0

How frameworks, and especially JavaScript frameworks, have control and them call my own main code? Is frameworks always run before my own code? I know the difference between a library and a framework, but I'm not sure how the frameworks have been implemented.

Library:
I think the library is a code that mainly defines the functions. I can use them if I want. Control is on my code and it calls the library.
index.html

<html>
 <head>
  <script src="URL to jQuery-lib.js"
  <script src="./my_code.js"
 </head>
 <body>
 </body>
</html>

jQuery-lib.js

function one_jquery_function() {
   something
 }

my_code.js

one_jquery_function()

Framework:
I Think framework is a code that is executed before my own code and at its desired points it retrieves my code from spesific places. So framework has control and it calls my code when needed.
index.html

<html>
 <head>
  <script src="URL to JS-framework.js"
  <script src="./my_code.js"
 </head>
 <body>
 </body>
</html>

JS-framework.js

...
setup...
...
run (i.e. call) my_code.js
...

my_code.js

framework decides
jsdev975
  • 1
  • 2

0 Answers0