Thread: Javascript question
Results 1 to 8 of 8
-
6th Aug 2009, 9:15 PM #1
Javascript question
If a web page - not one of mine - had a line of code that called the file "google-analytics.com/ga.js" and repeated that line of code 200 times, would it run that file 200 times each time the page loaded or does it know to only run a script once no matter how often it is listed?
Dennis, Francois, Melba and Smasher are competing to see who can wine and dine Lola Whitecastle and win the contract to write her memoirs. Can Dennis learn how to be charming? Can Francois concentrate on anything else when food is on the table? Will Smasher keep his temper under control?
If only the 28th century didn't keep popping up to get in Dennis's way...
#dammitbrent
The eleventh annual Brenty Four serial is another Planet Skaro exclusive. A new episode each day until Christmas in the Brenty Four-um.
-
6th Aug 2009, 10:49 PM #2
Does sound messy - I think generally with such a declaration it doesn't run the file 200 times, but there's no need for it and it's messy.
Usually with such a call, it's setting up a reference library, which isn't used until a related function is called.
Hope that helps - I'm not an expert in JS, but in comparable languages, it'd help to see the full line to know what it's doing with the line, I'm assuming it's a kind of library call. If it's however an OPEN FILE type call - yes indeed it would open it 200 times.
Still sounds very messy though.Remember, just because Davros is dead doesn't mean the Dalek menace has been contained ......
-
6th Aug 2009, 10:50 PM #3
I know I'm saying messy a lot - I need coffee!
Remember, just because Davros is dead doesn't mean the Dalek menace has been contained ......
-
7th Aug 2009, 8:35 AM #4
The full section of code is -
<!--Google analytics tag-->
<SCRIPT type=text/javascript>
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</SCRIPT>
<SCRIPT src="http://www.google-analytics.com/ga.js" type=text/javascript></SCRIPT>
<SCRIPT type=text/javascript>
try {
var pageTracker = _gat._getTracker("**********");
pageTracker._setDomainName("none");
pageTracker._setAllowLinker(true);
pageTracker._trackPageview();
} catch(err) {}
</SCRIPT>
<!--Google analytics tag-->
</body>
The part in bold appears 199 times before the code continues.Dennis, Francois, Melba and Smasher are competing to see who can wine and dine Lola Whitecastle and win the contract to write her memoirs. Can Dennis learn how to be charming? Can Francois concentrate on anything else when food is on the table? Will Smasher keep his temper under control?
If only the 28th century didn't keep popping up to get in Dennis's way...
#dammitbrent
The eleventh annual Brenty Four serial is another Planet Skaro exclusive. A new episode each day until Christmas in the Brenty Four-um.
-
7th Aug 2009, 9:14 AM #5
http://www.jsworkshop.com/articles/02scriptsrc.html
http://www.quirksmode.org/js/placejs.html
Right, reading through the lines, it says for each use of <SCRIPT> it will place all the code within the script. So all those itterations will possibly cause multiple downloads of that file at script run time, making the webpage larger in memory and slower than required.
As stated I believe it would be better to drop to 1 use of that script call.Remember, just because Davros is dead doesn't mean the Dalek menace has been contained ......
-
7th Aug 2009, 9:50 AM #6
That's what I thought - it's on every page of our company intranet and it's running like a bollard. I needed confirmation before telling them they need to remove it. Javascript doesn't work well in our CITRIX environment anyway and adding a load of superfluous code isn't the answer.
Thanks hugely - I've had a quicker response from New Zealand than I got from upstairs. That's 2009 for you.Dennis, Francois, Melba and Smasher are competing to see who can wine and dine Lola Whitecastle and win the contract to write her memoirs. Can Dennis learn how to be charming? Can Francois concentrate on anything else when food is on the table? Will Smasher keep his temper under control?
If only the 28th century didn't keep popping up to get in Dennis's way...
#dammitbrent
The eleventh annual Brenty Four serial is another Planet Skaro exclusive. A new episode each day until Christmas in the Brenty Four-um.
-
7th Aug 2009, 10:14 AM #7
Like I say I'm making a guestimate on that, but no-way is this a sensible thing.
Mind you ever turned and MS Office into a HTML page - it's full of junk!Remember, just because Davros is dead doesn't mean the Dalek menace has been contained ......
-
9th Aug 2009, 4:14 PM #8
Did that the first time I tried writing documents as HTML pages by just resaving them as Word files... wound up spending hours tearing out all the unnecessary formatting code to the point where I found it was easier to redo them all them from scratch as very basic HTML!
We ride tornadoes. We eat tomatoes.
Similar Threads
-
A Blu Ray question
By Anthony Williams in forum DVD and Blu-rayReplies: 6Last Post: 30th Apr 2012, 10:58 AM -
Wii Question
By Rob McCow in forum Mr Smith, I Need You!Replies: 7Last Post: 26th Dec 2009, 8:13 PM -
Astronomy question
By Jamie McCrimmon in forum General ForumReplies: 6Last Post: 8th Dec 2008, 4:23 PM
PSAudios 6.1. Bless You Doctor Who
[/URL] (Click for large version) Doctor Who A thrilling two-part adventure starring Brendan Jones & Paul Monk & Paul Monk Bless You,...
23rd Nov 2020, 3:02 PM