Reputation: 438
I am not sure what to call this question so any revise is welcomed!!! I am trying to learn to keep a clean js library structure of third party scripts as well as my own. I have no knowledge other than the basic method of adding js files to my page other than the old way..
I found this on searching and it makes some sense to me seeing that I am not real good with javascript or jquery https://github.com/volojs/create-template
my question is I have a folder structure as follows
in my index.html file i have my link to jquery and to the file called app.js
but I am confused on how to get this to work how to i call the files from the directory?
Basicly I want to call multi js files from 1 file
Upvotes: 2
Views: 66
Reputation: 698
If I understood correctly u need files included from app.js and app.js included in index.html.
app.js
function dynamicallyLoadScript(url) {
var script = document.createElement("script"); // Make a script DOM node
script.src = url; // Set it's src to the provided URL
document.head.appendChild(script); // Add it to the end of the head section of the page (could change 'head' to 'body' to add it to the end of the body section instead)
}
dynamicallyLoadScript('assets/js/lib/bootstrap/test.js');
dynamicallyLoadScript('assets/js/lib/gsap/test.js');
index.html
<script src="app.js"></script>
function taken from here. Guy answers almost all the related questions.
Upvotes: 1