Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #34175

Re: Dynamically load js files.

Newsgroups comp.lang.javascript
Subject Re: Dynamically load js files.
From "Evertjan." <exxjxw.hannivoort@inter.nl.net>
References <2d97db74-9dc2-4a99-bcf8-68944b7eef51@googlegroups.com>
Date 2017-10-24 15:00 +0200
Message-ID <XnsA81898AFD78FCeejj99@194.109.6.166> (permalink)

Show all headers | View raw


jonas.thornvall@gmail.com wrote on 24 Oct 2017 in comp.lang.javascript:

> I understand if you find the question confusing, but how can i load a js
> SRC file on demand or a file that holds many <SCRIPT SRC=""> tags
> dynamically? 

I suppose you mean 'download' by 'load'?

Automatic downloading with a browser 
leads to all kinds of security issues.

However, downloading any file fromm the web can be done
easily with a cscript/wscript script in VBS [or JS].

Example in VBS [not tested!!!!!]:

function getJSfile(fileName, sourceURL, targetDir)
  dim xHttp: Set xHttp = createobject("Microsoft.XMLHTTP")
  dim bStrm: Set bStrm = createobject("Adodb.Stream")
  xHttp.Open "GET", sourceURL & fileName, False
  xHttp.Send
  with bStrm
    .type = 1 '''binary
    .open
    .write xHttp.responseBody
    .savetofile targetDir & fileName, 2 '''overwrite
  end with
end function

getJSfile "xxx.js", "http://any.com/", "D:\temp\"

==================

To detect inner <script src="...js"> URL you can easily write 
a Regex search code and downlowd them recursively with the above getJSfile.

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Dynamically load js files. jonas.thornvall@gmail.com - 2017-10-24 04:29 -0700
  Re: Dynamically load js files. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-10-24 15:00 +0200
  Re: Dynamically load js files. Dr.Kral@nyc.rr.com - 2017-10-24 12:48 -0400
    Re: Dynamically load js files. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-10-25 00:09 +0200
      Re: Dynamically load js files. John G Harris <niam@jghnorth.org.uk.invalid> - 2017-10-25 15:18 +0100
        Re: Dynamically load js files. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-10-25 17:27 +0200
          Re: Dynamically load js files. John G Harris <niam@jghnorth.org.uk.invalid> - 2017-10-26 19:56 +0100
            Re: Dynamically load js files. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-10-26 23:06 +0200

csiph-web