简体   繁体   中英

javascript .js file external url

I am using gnuplot-js https://github.com/chhu/gnuplot-JS when I am without my laptop at university. Is it possible to use an external url for gnuplot.js file? I host index.html, gnuplot_api.js on https://mywebsite.com/ but I would like to use another url for gnuplot.js file (for example https://external.com/blabla/ok/no/gnuplot.js ) because this file is really big!

Maybe this is the part I should edit on index.html. How? :

 <script src='gnuplot_api.js'></script> <script> gnuplot = new Gnuplot('gnuplot.js'); gnuplot.onOutput = function(text) { document.getElementById('output').value += text + '\n'; document.getElementById('output').scrollTop = 99999; };
or maybe this part on gnuplot_api.js?:

 var Gnuplot = function(js_filename) { this.worker = new Worker(js_filename); this.output = []; this.error = []; this.isRunning = false;

Thank you very much for your support

It appears Gnuplot use an onboard webworker, so the path provided to the constructor should be on the same domain than the script.

 <script src='https://cdn.jsdelivr.net/gh/chhu/gnuplot-JS/www/gnuplot_api.js'></script> <script> gnuplot = new Gnuplot('https://cdn.jsdelivr.net/gh/chhu/gnuplot-JS/www/gnuplot.js'); </script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM