How to call a remote JavaScript code in some code deposit (such as GitHub)?

I want to call a remote JavaScript code which is located in GitHub (raw version), from my web browser’s user script manager (Tampermonkey).

The JavaScript code on GitHub was already tested locally (by copy-pasting it into the browser’s console and executing it) and is working.

I tried to call the remote script this way:

var githubScript = document.createElement('script');
script.type = 'text/javascript';
script.src = 'GITHUB_URL';
document.head.appendChild(githubScript);

But, the only output I get in console is the file itself (i.e. no execution of the actual code in the file occurs).

Please suggest what have I done wrong (perhaps I lack a command to actually run the code?).

There are libraries such as jsdelivr that are designed to let you load code from github repositories.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.