Answer the question
In order to leave comments, you need to log in
How to import the contents of a js file and not a link to it?
How to connect scripts that are in node_modules so that in the final file there is not a link to the file, but the content in the file?
Answer the question
In order to leave comments, you need to log in
via ajax...
why is this method bad?
function include(filename) {
var js = document.createElement('script');
js.setAttribute('src', filename);
document.getElementsByTagName('HEAD')[0].appendChild(js);
var cur_file = {};
cur_file[window.location.href] = 1;
if (!window.js_file)
window.js_file = {};
if (!window.js_file.includes)
window.js_file.includes = cur_file;
if (!window.js_file.includes[filename]) {
window.js_file.includes[filename] = 1;
} else {
window.js_file.includes[filename]++;
}
return window.js_file.includes[filename];
}
(function () {
var JSlist = [];
JSlist.push('/js/jquery-easing.js');
JSlist.push('/js/jquery.maskedinput.js');
...
JSlist.forEach(function (URL) {
include(URL);
});
}());
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question