Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #31643 > unrolled thread
| Started by | justaguy <lichunshen84@gmail.com> |
|---|---|
| First post | 2016-11-05 14:35 -0700 |
| Last post | 2016-11-06 06:44 -0800 |
| Articles | 12 — 4 participants |
Back to article view | Back to comp.lang.javascript
What's an efficient way to record the number of loading / calling of a JS script file? justaguy <lichunshen84@gmail.com> - 2016-11-05 14:35 -0700
Re: What's an efficient way to record the number of loading / calling of a JS script file? Luuk <luuk@invalid.lan> - 2016-11-06 09:49 +0100
Re: What's an efficient way to record the number of loading / calling of a JS script file? justaguy <lichunshen84@gmail.com> - 2016-11-06 06:42 -0800
Re: What's an efficient way to record the number of loading / calling of a JS script file? Luuk <luuk@invalid.lan> - 2016-11-06 19:21 +0100
Re: What's an efficient way to record the number of loading / calling of a JS script file? justaguy <lichunshen84@gmail.com> - 2016-11-06 12:33 -0800
Re: What's an efficient way to record the number of loading / calling of a JS script file? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-11-07 09:48 +0100
Re: What's an efficient way to record the number of loading / calling of a JS script file? justaguy <lichunshen84@gmail.com> - 2016-11-07 14:23 -0800
Re: What's an efficient way to record the number of loading / calling of a JS script file? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-11-07 23:51 +0100
Re: What's an efficient way to record the number of loading / calling of a JS script file? justaguy <lichunshen84@gmail.com> - 2016-11-08 08:01 -0800
Re: What's an efficient way to record the number of loading / calling of a JS script file? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-11-08 19:19 +0100
Re: What's an efficient way to record the number of loading / calling of a JS script file? JJ <jj4public@vfemail.net> - 2016-11-06 20:31 +0700
Re: What's an efficient way to record the number of loading / calling of a JS script file? justaguy <lichunshen84@gmail.com> - 2016-11-06 06:44 -0800
| From | justaguy <lichunshen84@gmail.com> |
|---|---|
| Date | 2016-11-05 14:35 -0700 |
| Subject | What's an efficient way to record the number of loading / calling of a JS script file? |
| Message-ID | <5c66e503-f057-4113-ae7a-d177d882b78c@googlegroups.com> |
Per subject line, thanks.
[toc] | [next] | [standalone]
| From | Luuk <luuk@invalid.lan> |
|---|---|
| Date | 2016-11-06 09:49 +0100 |
| Message-ID | <581eee8e$0$857$e4fe514c@news.xs4all.nl> |
| In reply to | #31643 |
On 05-11-16 22:35, justaguy wrote: > > Per subject line, thanks. > # grep test.js /var/log/apache2/www-access_log | wc -l 42
[toc] | [prev] | [next] | [standalone]
| From | justaguy <lichunshen84@gmail.com> |
|---|---|
| Date | 2016-11-06 06:42 -0800 |
| Message-ID | <e8a3ad62-b789-48c2-b0a8-ef77a0bab0a8@googlegroups.com> |
| In reply to | #31644 |
I'm on windows os, so, probably we dont have grep command utility. The other thing is i've disabled web server log. Thanks tho.
[toc] | [prev] | [next] | [standalone]
| From | Luuk <luuk@invalid.lan> |
|---|---|
| Date | 2016-11-06 19:21 +0100 |
| Message-ID | <581f749e$0$881$e4fe514c@news.xs4all.nl> |
| In reply to | #31646 |
On 06-11-16 15:42, justaguy wrote: > I'm on windows os, so, probably we dont have grep command utility. > http://gnuwin32.sourceforge.net/packages/grep.htm or http://www.powergrep.com/ > The other thing is i've disabled web server log. Thanks tho. The most efficient way to record how many time a client has initiated a load for that script (which is my interpretation of your question), is to enable server side logging.
[toc] | [prev] | [next] | [standalone]
| From | justaguy <lichunshen84@gmail.com> |
|---|---|
| Date | 2016-11-06 12:33 -0800 |
| Message-ID | <a12cea6a-43af-48d5-902d-04c041ffbbe8@googlegroups.com> |
| In reply to | #31648 |
On Sunday, November 6, 2016 at 1:21:49 PM UTC-5, Luuk wrote: > On 06-11-16 15:42, justaguy wrote: > > I'm on windows os, so, probably we dont have grep command utility. > > > > http://gnuwin32.sourceforge.net/packages/grep.htm > or > http://www.powergrep.com/ > > > The other thing is i've disabled web server log. Thanks tho. > > The most efficient way to record how many time a client has initiated a > load for that script (which is my interpretation of your question), is > to enable server side logging. ok, thanks.
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2016-11-07 09:48 +0100 |
| Message-ID | <XnsA6B963CDAFB85eejj99@194.109.6.166> |
| In reply to | #31648 |
Luuk <luuk@invalid.lan> wrote on 06 Nov 2016 in comp.lang.javascript:
>> The other thing is i've disabled web server log. Thanks tho.
>
> The most efficient way to record how many time a client has initiated a
> load for that script (which is my interpretation of your question), is
> to enable server side logging.
Which will also accomodate for not counting the possible clientside re-use
of a cashed version.
Using classic ASP:
// js-file content here, call this file "myJS.asp"
<%@ Language="JScript" %>
<%
var ForReading = 1, ForWriting = 2, count, f;
var filename = Server.MapPath("count-myJS-asp.txt");
var fso = new ActiveXObject("Scripting.FileSystemObject");
if (fso.FileExists(filename)) {
f = fso.OpenTextFile(filename, ForReading);
count = f.ReadAll();
f.Close();
} else {
var f = fso.CreateTextFile(filename, true);
f.Close();
count = 0;
};
f = fso.OpenTextFile(filename, ForWriting);
// count = -1; // reset counter to 0
f.Write(++count);
f.Close();
%>
================
Read the number into an html-file:
<iframe src = 'count-myJS-asp.txt'> </iframe>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | justaguy <lichunshen84@gmail.com> |
|---|---|
| Date | 2016-11-07 14:23 -0800 |
| Message-ID | <0aecf8a3-3bda-41f9-8169-0401e2771dc4@googlegroups.com> |
| In reply to | #31650 |
On Monday, November 7, 2016 at 3:48:44 AM UTC-5, Evertjan. wrote:
> Luuk <luuk@invalid.lan> wrote on 06 Nov 2016 in comp.lang.javascript:
>
> >> The other thing is i've disabled web server log. Thanks tho.
> >
> > The most efficient way to record how many time a client has initiated a
> > load for that script (which is my interpretation of your question), is
> > to enable server side logging.
>
> Which will also accomodate for not counting the possible clientside re-use
> of a cashed version.
>
> Using classic ASP:
>
> // js-file content here, call this file "myJS.asp"
> <%@ Language="JScript" %>
> <%
> var ForReading = 1, ForWriting = 2, count, f;
> var filename = Server.MapPath("count-myJS-asp.txt");
> var fso = new ActiveXObject("Scripting.FileSystemObject");
>
> if (fso.FileExists(filename)) {
> f = fso.OpenTextFile(filename, ForReading);
> count = f.ReadAll();
> f.Close();
> } else {
> var f = fso.CreateTextFile(filename, true);
> f.Close();
> count = 0;
> };
>
> f = fso.OpenTextFile(filename, ForWriting);
> // count = -1; // reset counter to 0
> f.Write(++count);
> f.Close();
> %>
> ================
>
> Read the number into an html-file:
>
> <iframe src = 'count-myJS-asp.txt'> </iframe>
>
>
I appreciate it though I'm not an ASP developer.
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2016-11-07 23:51 +0100 |
| Message-ID | <XnsA6B9F2BE18FDBeejj99@194.109.6.166> |
| In reply to | #31654 |
justaguy <lichunshen84@gmail.com> wrote on 07 Nov 2016 in
comp.lang.javascript:
> On Monday, November 7, 2016 at 3:48:44 AM UTC-5, Evertjan. wrote:
>> Luuk <luuk@invalid.lan> wrote on 06 Nov 2016 in comp.lang.javascript:
>>
>> >> The other thing is i've disabled web server log. Thanks tho.
>> >
>> > The most efficient way to record how many time a client has initiated
>> > a load for that script (which is my interpretation of your question),
>> > is to enable server side logging.
>>
>> Which will also accomodate for not counting the possible clientside
>> re-use of a cashed version.
>>
>> Using classic ASP:
>>
>> // js-file content here, call this file "myJS.asp"
>> <%@ Language="JScript" %>
>> <%
>> var ForReading = 1, ForWriting = 2, count, f;
>> var filename = Server.MapPath("count-myJS-asp.txt");
>> var fso = new ActiveXObject("Scripting.FileSystemObject");
>>
>> if (fso.FileExists(filename)) {
>> f = fso.OpenTextFile(filename, ForReading);
>> count = f.ReadAll();
>> f.Close();
>> } else {
>> var f = fso.CreateTextFile(filename, true);
>> f.Close();
>> count = 0;
>> };
>>
>> f = fso.OpenTextFile(filename, ForWriting);
>> // count = -1; // reset counter to 0
>> f.Write(++count);
>> f.Close();
>> %>
>> ================
>>
>> Read the number into an html-file:
>>
>> <iframe src = 'count-myJS-asp.txt'> </iframe>
>>
>>
>
> I appreciate it though I'm not an ASP developer.
ASP is fully developed, why would you want to develop it? [joke]
You can do exactly the same in PHP, [or in VBScript, btw]
but then, this is a Javascript NG,
so serverside JS is on topic,
while PHP is not.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | justaguy <lichunshen84@gmail.com> |
|---|---|
| Date | 2016-11-08 08:01 -0800 |
| Message-ID | <731d3836-d362-4bf8-be61-c4e4620877d4@googlegroups.com> |
| In reply to | #31655 |
On Monday, November 7, 2016 at 5:52:12 PM UTC-5, Evertjan. wrote:
> wrote on 07 Nov 2016 in
> comp.lang.javascript:
>
> > On Monday, November 7, 2016 at 3:48:44 AM UTC-5, Evertjan. wrote:
> >> Luuk <luuk@invalid.lan> wrote on 06 Nov 2016 in comp.lang.javascript:
> >>
> >> >> The other thing is i've disabled web server log. Thanks tho.
> >> >
> >> > The most efficient way to record how many time a client has initiated
> >> > a load for that script (which is my interpretation of your question),
> >> > is to enable server side logging.
> >>
> >> Which will also accomodate for not counting the possible clientside
> >> re-use of a cashed version.
> >>
> >> Using classic ASP:
> >>
> >> // js-file content here, call this file "myJS.asp"
> >> <%@ Language="JScript" %>
> >> <%
> >> var ForReading = 1, ForWriting = 2, count, f;
> >> var filename = Server.MapPath("count-myJS-asp.txt");
> >> var fso = new ActiveXObject("Scripting.FileSystemObject");
> >>
> >> if (fso.FileExists(filename)) {
> >> f = fso.OpenTextFile(filename, ForReading);
> >> count = f.ReadAll();
> >> f.Close();
> >> } else {
> >> var f = fso.CreateTextFile(filename, true);
> >> f.Close();
> >> count = 0;
> >> };
> >>
> >> f = fso.OpenTextFile(filename, ForWriting);
> >> // count = -1; // reset counter to 0
> >> f.Write(++count);
> >> f.Close();
> >> %>
> >> ================
> >>
> >> Read the number into an html-file:
> >>
> >> <iframe src = 'count-myJS-asp.txt'> </iframe>
> >>
> >>
> >
> > I appreciate it though I'm not an ASP developer.
>
> ASP is fully developed, why would you want to develop it? [joke]
>
> You can do exactly the same in PHP, [or in VBScript, btw]
> but then, this is a Javascript NG,
> so serverside JS is on topic,
> while PHP is not.
>
>
Ok.
I have a new question titled "This question has two parts: 1) Level of Difficulty (2) Level of Elegance".
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2016-11-08 19:19 +0100 |
| Message-ID | <XnsA6BAC48ABEFCBeejj99@194.109.6.166> |
| In reply to | #31658 |
justaguy <lichunshen84@gmail.com> wrote on 08 Nov 2016 in
comp.lang.javascript:
> On Monday, November 7, 2016 at 5:52:12 PM UTC-5, Evertjan. wrote:
>> wrote on 07 Nov 2016 in
>> comp.lang.javascript:
>>
>> > On Monday, November 7, 2016 at 3:48:44 AM UTC-5, Evertjan. wrote:
>> >> Luuk <luuk@invalid.lan> wrote on 06 Nov 2016 in
>> >> comp.lang.javascript:
>> >>
>> >> >> The other thing is i've disabled web server log. Thanks tho.
>> >> >
>> >> > The most efficient way to record how many time a client has
>> >> > initiated a load for that script (which is my interpretation of
>> >> > your question), is to enable server side logging.
>> >>
>> >> Which will also accomodate for not counting the possible clientside
>> >> re-use of a cashed version.
>> >>
>> >> Using classic ASP:
>> >>
>> >> // js-file content here, call this file "myJS.asp"
>> >> <%@ Language="JScript" %>
>> >> <%
>> >> var ForReading = 1, ForWriting = 2, count, f;
>> >> var filename = Server.MapPath("count-myJS-asp.txt");
>> >> var fso = new ActiveXObject("Scripting.FileSystemObject");
>> >>
>> >> if (fso.FileExists(filename)) {
>> >> f = fso.OpenTextFile(filename, ForReading);
>> >> count = f.ReadAll();
>> >> f.Close();
>> >> } else {
>> >> var f = fso.CreateTextFile(filename, true);
>> >> f.Close();
>> >> count = 0;
>> >> };
>> >>
>> >> f = fso.OpenTextFile(filename, ForWriting);
>> >> // count = -1; // reset counter to 0
>> >> f.Write(++count);
>> >> f.Close();
>> >> %>
>> >> ================
>> >>
>> >> Read the number into an html-file:
>> >>
>> >> <iframe src = 'count-myJS-asp.txt'> </iframe>
>> >>
>> >>
>> >
>> > I appreciate it though I'm not an ASP developer.
>>
>> ASP is fully developed, why would you want to develop it? [joke]
>>
>> You can do exactly the same in PHP, [or in VBScript, btw]
>> but then, this is a Javascript NG,
>> so serverside JS is on topic,
>> while PHP is not.
>>
>
> I have a new question titled "This question has two parts: 1) Level of
> Difficulty (2) Level of Elegance".
No, you don't, meaning you should not.
You should research my code,
try to understand it,
then search for php equivalents,
and try to implement it there.
You are like a man begging for the right turn at every corner,
while holding a map and a streetguide under his arm,
afraid that looking at it would exhaust him.
And btw, I repeat, while serverside javascript is on topic here, php is not.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | JJ <jj4public@vfemail.net> |
|---|---|
| Date | 2016-11-06 20:31 +0700 |
| Message-ID | <1ou8v9ezbw5oj$.su5crqs4yrdh.dlg@40tude.net> |
| In reply to | #31643 |
On Sat, 5 Nov 2016 14:35:07 -0700 (PDT), justaguy wrote: > Per subject line, thanks. If you meant from the web browser or client-side JavaScript, monitor the SCRIPT element's `load` and `error` events, and monitor the global object's `error` event. The SCRIPT element's `load` event will fire if the script code has been loaded, parsed, and executed. The SCRIPT element's `error` event will fire if the script code has failed to be loaded. The global object's `error` event will fire if a script code has an unhandled error. You'll need to have a count of the total number of external scripts either at design time (i.e. server side), or at run time (i.e. client side). If from client side, use the `document.scripts` to determine the number of external scripts. If you load the JavaScript files using SCRIPT elements as external scripts, then you'll need to monitor the events using the `onload` and `onerror` attributes of the SCRIPT elements because the resources may load very fast especially if you have fast network or if you serve the files from a local web server. If you monitor the events using the SCRIPT element object's `onload`/`onerror` properties, or using `addEventListener()`, the events may have already been fired before you have the chance to attach the event listeners. If you load the JavaScript files using XHR, then you'll have to also listen to the XHR's `load` and `error` events, in order to determine whether a JavaScript file is still loading or not.
[toc] | [prev] | [next] | [standalone]
| From | justaguy <lichunshen84@gmail.com> |
|---|---|
| Date | 2016-11-06 06:44 -0800 |
| Message-ID | <fd37985f-3308-4fc7-8570-449745a9c113@googlegroups.com> |
| In reply to | #31645 |
From server side. Thanks.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web