Skip to content Skip to sidebar Skip to footer

How To Load External Js Script From Url In Node.js

I have a node.js server running on a VPS and I want to use a js script that is served from another server, something like: http://example.com/api/js How do I load this script and

Solution 1:

exec('wget http://example.com/api/js', function(stdout) { }); should do the trick. If you need advanced control, use http module.

Solution 2:

Use GGScript.

constGGScript = require("ggscript")
GGScript("http://example.com/api/js").then(() => {
    console.log("Finished loading file.")
})

Post a Comment for "How To Load External Js Script From Url In Node.js"