Add link to .js file in javascript file?

What is the correct syntax for adding an external link to a JavaScript file (.js) in another JavaScript file?

+3
source share
3 answers

No.

You can add a block <script>to the document, but it will execute asynchronously.

+4
source

Alternatively save all your .js files in a php file.

<script src="js.php" type="text/javascript"></script>

PHP:

<?php
require 'js/myjs1.js';
require 'js/myjs2.js';
?>
+1
source

I assume that you can upload the contents of the file via ajax and use eval().

+1
source

Source: https://habr.com/ru/post/1770202/


All Articles