Rajanikant Hawaldar
How do I include a JavaScript file in another JavaScript file?

How do I include a JavaScript file in another JavaScript file?

By Rajanikant Hawaldar in JavaScript on Oct 10 2020
  • Sanjay Makwana
    Dec, 2020 25

    In a javascript code, you can load another js file as below:
    var imported = document.createElement(‘script’);
    imported.src = ‘/path/to/imported/script’;
    document.head.appendChild(imported);

    And in a JQuery, you can load another js file as below:
    $.getScript(‘/path of file/script.js’, function()
    {
    //Your another JS file is loaded now
    });

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS