Is it possible to somehow connect one js file to another? something like:
include 'js_prev.js'; console.log('...'); Is it possible to somehow connect one js file to another? something like:
include 'js_prev.js'; console.log('...'); You can write such a function
function include(url) { var script = document.createElement('script'); script.src = url; document.getElementsByTagName('head')[0].appendChild(script); } and use
include('js_prev.js'); Another option is to use jQuery.getScript() . Good examples are in the native documentation .
You can also look towards RequireJS and CommonJS . But these are more costly methods, it will be necessary to reorganize all the scripts into a modular architecture. The implementation of the last one (CommonJS) is the basis of the node.js modules.
In addition, native module support has been added to the new javascript standard (ECMAScript 6).
Source: https://ru.stackoverflow.com/questions/517022/
All Articles