Adding two scripts inside one javascript file

1.6k views Asked by At

I have a Content Editor in SharePoint online page I want to add two scripts within a single Javascript "content.js" and assign "content.js" to the content editor, those two scripts are different, one is a Javascript code to develop something and the other script is Jquery script to design and maintain Select tag that I have.
How to do that with single script

Thank you

1

There are 1 answers

2
Stevangelista On BEST ANSWER

You can do something like this within your "content.js" file that you load up via Content Editor:

document.write('<script type="text/javascript" src="../Resources/jquery.min.js"><\/script>');
document.write('<script type="text/javascript" src="../Resources/YourCustom.js"><\/script>');

Note the use of the escaping slash in the closing </script> tag; this is the simplest approach to loading other JS files via document.write in JS (as opposed to other techniques that say split the tag into two strings).

An alternative would also be to load an HTM file via your Content Editor & have said HTM file load the JS files you wish.