Jump to content

Unresponsive Script Message


johnnyg24

Recommended Posts

I have a script that when I run it an "Unresponsive Script" message pops up. When I debug in FireFox, it highlights the line that is 'return oneRecord'. Any ideas why? I have posted my script below. Here is the link if anyone wants to try it. The xml doc it is trying to load is very long and will not be this long when the page is published.

function loadXMLDoc(url) {			initMenu();		 var req = null;		 try {			req = new XMLHttpRequest();			req.overrideMimeType("text/xml");		 } catch(e) {			req = new ActiveXObject("Msxml2.XMLHTTP");		 }		 if (req) {		 	var xDoc = null;			req.open("GET", "http://www.estout.com/ordering/allitems.xml", true);			req.onreadystatechange = function() {			   if (req.readyState == 4) {				  if (req.status == 200) {					 xDoc = req.responseXML;					 if (xDoc && typeof xDoc.childNodes != "undefined" && xDoc.childNodes.length == 0) {						xDoc = null;					 } else {						for (var i = 0; i < xDoc.getElementsByTagName("sku").length; i++) {						   db[db.length] = getOneSku(xDoc, i);						}											 }				  } else {					 alert("There was a problem retrieving the XML data:\n" + req.statusText);				  }			   }			}			req.send(null);		 }		 		  }	  var db = new Array();	  	  function getOneSku(xDoc, i) {		 var oneRecord = new Object();		 var oneElem = xDoc.getElementsByTagName("sku")[i];		 oneRecord.idNum = oneElem.getElementsByTagName("idNum")[0].firstChild.data;		 oneRecord.desc = oneElem.getElementsByTagName("desc")[0].firstChild.data;		 oneRecord.pName = oneElem.getElementsByTagName("pattern")[0].firstChild.data;		 oneRecord.construction = oneElem.getElementsByTagName("construction")[0].firstChild.data;		 oneRecord.pStyle = oneElem.getElementsByTagName("pStyle")[0].firstChild.data;		 oneRecord.pClass = oneElem.getElementsByTagName("pClass")[0].firstChild.data;		 oneRecord.confCode = oneElem.getElementsByTagName("confCode")[0].firstChild.data;		 oneRecord.pCountry = oneElem.getElementsByTagName("country")[0].firstChild.data;		 oneRecord.rr = oneElem.getElementsByTagName("rr")[0].firstChild.data;		 oneRecord.pWide = oneElem.getElementsByTagName("pWide")[0].firstChild.data;		 oneRecord.vRepeat = oneElem.getElementsByTagName("verticalR")[0].firstChild.data;		 oneRecord.hRepeat = oneElem.getElementsByTagName("horizontalR")[0].firstChild.data;		 oneRecord.pFiber = oneElem.getElementsByTagName("fiber")[0].firstChild.data;		 oneRecord.finishTest = oneElem.getElementsByTagName("finish")[0].firstChild.data;		 oneRecord.pTest = oneElem.getElementsByTagName("pTesting")[0].firstChild.data;		 oneRecord.pColor = oneElem.getElementsByTagName("pColor")[0].firstChild.data;		 oneRecord.book = oneElem.getElementsByTagName("bookNbr")[0].firstChild.data;		 oneRecord.bookTXT = oneElem.getElementsByTagName("bookTXT")[0].firstChild.data;		 oneRecord.skuImg = oneElem.getElementsByTagName("skuImg")[0].firstChild.data;		 return oneRecord;		 idDetail();		 otherColors();		 }		 		 	function fabricSearch(){	 		page = 1;	drawTextTableTrial();	}				function drawTextTableTrial() {				var per_page = 20		var colorSelect = document.getElementById("colorNumber").value;		   	var classSelect = document.getElementById("classNumber").value;		var styleSelect = document.getElementById("styleNumber").value;		var consSelect = document.getElementById("constructionNumber").value;		var nr = 0;		var num_matches = 0;		deleteRows(document.getElementById("mainTableBody"));			for (var i = 0; i < db.length; i++) {								if (db[i].pColor == colorSelect || db[i].construction == consSelect || db[i].pClass == classSelect || db[i].pStyle == styleSelect) {											if (colorSelect != "" && db[i].pColor != colorSelect)					continue; // skip it - color doesnt match				  if (consSelect != "" && db[i].construction != consSelect)					continue; // skip it - construction doesnt match				  if (classSelect != "" && db[i].pClass != classSelect) 					continue; // class doesnt match				  if (styleSelect != "" && db[i].pStyle != styleSelect) 					continue; // style doesnt match 									num_matches++;					if (num_matches < (page - 1) * per_page)						  continue; // match goes on an earlier page												if (nr % 4 == 0){								  imgRow = document.getElementById("mainTableBody").insertRow(-1);					  txtRow = document.getElementById("mainTableBody").insertRow(-1);				}								var cellA=imgRow.insertCell(0);								var cellAA=txtRow.insertCell(0);												im = document.createElement("img");				im.src = db[i].skuImg;				im.setAttribute('width', 150);		 		im.setAttribute('height', 150);				cellA.appendChild(im);																lk = document.createElement("a");				lk.href = "sku.html?" + db[i].idNum;					lk.innerHTML = db[i].desc;				lk.setAttribute('class', 'BodyText');				cellAA.appendChild(lk);												nr++												if (nr == per_page)					  break; // stop the loop													}							}					 }		 	 		function drawTextTableName() {		var nr = 0;			var patternSelect = document.getElementById("patternNumber").value;			patternSelectU = patternSelect.toUpperCase();	   deleteRows(document.getElementById("mainTableBody"));			for (var i = 0; i < db.length; i++) {		   			if (db[i].pName == patternSelectU) {				if (patternSelectU != "" && db[i].pName != patternSelectU)					continue; 						if (nr % 4 == 0){								  imgRow = document.getElementById("mainTableBody").insertRow(-1);					  txtRow = document.getElementById("mainTableBody").insertRow(-1);				}								var cellA=imgRow.insertCell(0);								var cellAA=txtRow.insertCell(0);												im = document.createElement("img");				im.src = db[i].skuImg;				im.setAttribute('width', 150);		 		im.setAttribute('height', 150);				cellA.appendChild(im);																lk = document.createElement("a");				lk.href = "sku.html?" + db[i].idNum;					lk.innerHTML = db[i].desc;				lk.setAttribute('class', 'BodyText');				cellAA.appendChild(lk);												nr++								}			}					 }	  						function drawTextTableBook() {	   			var nr = 0;				var bookSelect = document.getElementById("bookNumber").value;				   deleteRows(document.getElementById("mainTableBody"));			for (var i = 0; i < db.length; i++) {						if (db[i].book == bookSelect) {				if (bookSelect != "" && db[i].book != bookSelect)					continue; 									if (nr % 4 == 0){								  imgRow = document.getElementById("mainTableBody").insertRow(-1);					  txtRow = document.getElementById("mainTableBody").insertRow(-1);				}								var cellA=imgRow.insertCell(0);								var cellAA=txtRow.insertCell(0);												im = document.createElement("img");				im.src = db[i].skuImg;				im.setAttribute('width', 150);		 		im.setAttribute('height', 150);				cellA.appendChild(im);																lk = document.createElement("a");				lk.href = "sku.html?" + db[i].idNum;					lk.innerHTML = db[i].desc;				lk.setAttribute('class', 'BodyText');				cellAA.appendChild(lk);												nr++																}			}					 }	  					 	  function deleteRows(tbl) {		 while (tbl.rows.length > 0) {			tbl.deleteRow(0);		 }	  }	  	   function idDetail() {		 	var re = location.search;			var idNumber = re.split("?").join("");								for (var i = 0; i < db.length; i++) {									if (db[i].idNum == idNumber){						break;					}				}												im = document.createElement("img");						im.src = db[i].skuImg;						im.setAttribute('width', 300);		 				im.setAttribute('height', 300);						document.getElementById("image").appendChild(im);						document.getElementById("patterndescription").innerHTML = db[i].desc;						document.getElementById("fiber").innerHTML = db[i].pFiber;						document.getElementById("country").innerHTML = db[i].pCountry;						document.getElementById("test").innerHTML = db[i].pTest;						document.getElementById("rr").innerHTML = db[i].rr;						document.getElementById("confinment").innerHTML = db[i].confCode;						document.getElementById("patternWidth").innerHTML = db[i].pWidth;						document.getElementById("vrepeat").innerHTML = db[i].vRepeat;						document.getElementById("hrepeat").innerHTML = db[i].hRepeat;						lk = document.createElement("a");						lk.href = db[i].skuImg;							lk.innerHTML = "Click here for larger image";						lk.setAttribute('class', 'BodyText');						document.getElementById("imgLink").appendChild(lk);												em = document.createElement("a");						em.href = "mailto:?subject=Stout Image " + db[i].desc + "&body=Thank you for choosing Stout.%0A%0AClick on the link below to view " + db[i].desc + "%0A%0A" + "http://www.estout.com/sku.html" + location.search;						em.innerHTML = "Email This Image";						em.setAttribute('class', 'BodyText');						document.getElementById("email").appendChild(em);		}					  	   function otherColors() {		   var nextRow = 0;		   var uriItems = new String(location.search);			var itemNumber = uriItems.split("?").join("");			var patternName = itemNumber.replace(/-.*/, "");				for (var i = 0; i < db.length; i++) {									if (db[i].pName == patternName){												if (nextRow % 4 == 0){								  newImgRow = document.getElementById("otherSkus").insertRow(-1);					  newTxtRow = document.getElementById("otherSkus").insertRow(-1);				}								var cellA1=newImgRow.insertCell(0);								var cellAA1=newTxtRow.insertCell(0);												im = document.createElement("img");				im.src = db[i].skuImg;				im.setAttribute('width', 150);		 		im.setAttribute('height', 150);				cellA1.appendChild(im);																lk = document.createElement("a");				lk.href = "sku.html?" + db[i].idNum;					lk.innerHTML = db[i].desc;				lk.setAttribute('class', 'BodyText');				cellAA1.appendChild(lk);												nextRow++															}				}		}	  	  	  // Sorting routines	  function selectSort(chooser) {		 switch (chooser.value) {		 case "byBook" :			db.sort(sortDBByBook);			break;		 case "byColor" :			db.sort(sortDBBypColorCode);			break;		 case "byDesc" :			db.sort(sortDBByDesc);			break;	   }		 		drawTextTableTrial();	  }	  function sortDBByBook(a, b) {		 if (document.getElementById("orderChooser").value == "inc") {			return (a.book < b.book) ? -1 : 1;		 } else {			return (a.book > b.book) ? -1 : 1;		 }	  }	  function sortDBBypColorCode(a, b) {		 if (document.getElementById("orderChooser").value == "inc") {			return (a.pColorCode < b.pColorCode) ? -1 : 1;		 } else {			return (a.pColorCode > b.pColorCode) ? -1 : 1;		 }	  }	  function sortDBByDesc(a, b) {		 if (document.getElementById("orderChooser").value == "inc") {			return (a.desc - b.desc) ? -1 : 1;		 } else {			return (b.desc - a.desc) ? -1 : 1;		 }	  }		  function selectOrder() {		 selectSort(document.getElementById("sortChooser"));	  }	  // Initialization called by onload	  function init() {		 loadXMLDoc("http://www.estout.com/ordering/allitems.xml");	  }	  	  	  ///side bar	  	  var activeMenuItem = new Array();		function isUlInArray(inputObj,ulObj){		while(inputObj && inputObj.id!='PushMenu'){			if(inputObj==ulObj)return true;			inputObj = inputObj.parentNode;					}				return false;	}		function showHideSub(e,inputObj)	{				if(!inputObj)inputObj=this;		var parentObj = inputObj.parentNode;		var ul = parentObj.getElementsByTagName('UL')[0];		if(activeMenuItem.length>0){			for(var no=0;no<activeMenuItem.length;no++){				if(!isUlInArray(ul,activeMenuItem[0]) && !isUlInArray(activeMenuItem[0],ul)){					activeMenuItem[no].style.display='none';					activeMenuItem.splice(no,1);					no--;				}			}					}		if(ul.offsetHeight == 0){			ul.style.display='block';			activeMenuItem.push(ul);		}else{			ul.style.display='none';		}	}		function showHidePath(inputObj)	{		var startTag = inputObj;		showHideSub(false,inputObj);		inputObj = inputObj.parentNode;		while(inputObj){						inputObj = inputObj.parentNode;			if(inputObj.tagName=='LI')showHideSub(false,inputObj.getElementsByTagName('A')[0]);			if(inputObj.id=='PushMenu')inputObj=false;			}			}		function initMenu()	{		var obj = document.getElementById('PushMenu');		var linkCounter=0;		var aTags = obj.getElementsByTagName('A');		var activeMenuItem = false;		var ActiveLink = false;		var thisLocationArray = location.href.split(/\//);		var fileNameThis = thisLocationArray[thisLocationArray.length-1];		if(fileNameThis.indexOf('?')>0)fileNameThis = fileNameThis.substr(0,fileNameThis.indexOf('?'));		if(fileNameThis.indexOf('#')>0)fileNameThis = fileNameThis.substr(0,fileNameThis.indexOf('#'));		for(var no=0;no<aTags.length;no++){			var parent = aTags[no].parentNode;			var subs = parent.getElementsByTagName('UL');			if(subs.length>0){				aTags[no].onclick = showHideSub;					linkCounter++;				aTags[no].id = 'aLink' + linkCounter;			}							if(aTags[no].href.indexOf(fileNameThis)>=0 && aTags[no].href.charAt(aTags[no].href.length-1)!='#'){								if(aTags[no].parentNode.parentNode){													var parentObj = aTags[no].parentNode.parentNode.parentNode;					var a = parentObj.getElementsByTagName('A')[0];					if(a.id && !ActiveLink){												ActiveLink = aTags[no];						activeMenuItem = a.id;					}				}			}				}				if(ActiveLink){			ActiveLink.className='ActiveLink';		}		if(activeMenuItem){			if(document.getElementById(activeMenuItem))showHidePath(document.getElementById(activeMenuItem));			}	}	//window.onload = initMenu;	  window.onload = init;

Link to comment
Share on other sites

It's going to be more efficient if you pass a single record to getonesku instead of the entire XML structure. When you pass the entire structure you're making a copy of it in memory, when you're only interested in a single record. Since you're looping through each record and sending the entire structure to the other function, that sounds like a lot of memory trashing going on as it continually allocates and de-allocates however much memory it needs to store the XML structure. Change that function to just build an object given a record, and pass each individual record to it instead of the whole shebang. Also, FYI: return oneRecord; idDetail(); otherColors();Those last 2 lines won't ever get executed.

Link to comment
Share on other sites

Would I change getOneSku(xDoc, i) to getOneSku(i)?I took the two function I was trying to call at the end of getOneSku and moved them to:

function loadXMLDoc(url) {			initMenu();		 var req = null;		 try {			req = new XMLHttpRequest();			req.overrideMimeType("text/xml");		 } catch(e) {			req = new ActiveXObject("Msxml2.XMLHTTP");		 }		 if (req) {		 	var xDoc = null;			req.open("GET", "http://www.estout.com/ordering/allitems.xml", true);			req.onreadystatechange = function() {			   if (req.readyState == 4) {				  if (req.status == 200) {					 xDoc = req.responseXML;					 if (xDoc && typeof xDoc.childNodes != "undefined" && xDoc.childNodes.length == 0) {						xDoc = null;					 } else {						for (var i = 0; i < xDoc.getElementsByTagName("sku").length; i++) {						   db[db.length] = getOneSku(i);						}				idDetail();		 		otherColors();					 }				  } else {					 alert("There was a problem retrieving the XML data:\n" + req.statusText);				  }			   }			}			req.send(null);		 }		 		  }

Link to comment
Share on other sites

Would I change getOneSku(xDoc, i) to getOneSku(i)?
It doesn't matter what you call the variable, but the point is to send the function a single record, not the entire structure. Right now the function takes the entire structure and an index, and gets the record at that index, then creates an object out of it. Might as well just send it the one record it needs.
Link to comment
Share on other sites

Doesn't the array (db) need to be built and inserted in my page as a "data island" so when I am looking for a specific record, or even a series of records, it can search through that array and locate it? I thought that was what getOneSku() was doing.

Link to comment
Share on other sites

You're still missing the point. getOneSku() doesn't use the entire object. It only uses one member of it: xDoc.getElementsByTagName("sku") . So instead of passing the whole object, pass just the member.

for (var i = 0; i < xDoc.getElementsByTagName("sku").length; i++) {	db[db.length] = getOneSku(xDoc.getElementsByTagName("sku")[i]);}...function getOneSku(oneElem) {	var oneRecord = new Object();	var oneElem = xDoc.getElementsByTagName("sku")[i]; // YOU CAN DELETE THIS LINE NOW

Of course, I find myself wondering why you'd want to pass the script an XML object and then copy it into a Javascript object. The copying itself is labor-intensive, and not necessary. Everywhere you use a member of db, you could just access the correct XML element. In other words, the XML object can remain your data island.Alternatively, the server could pass the data as a JSON string and you could start with a Javascript object. Transforming XML to JSON on your server is bound to be faster and less costly than doing the equivalent in the browser.EDIT: Another thing. At the end of getOneSku(), you return a big chunk of data. But when you get it, you copy it into the global object db. That's my point: db is global. There is no reason to go out and create a big data structure and pass it around when all you're going to do is copy it into this global object. That is, instead of temporarily storing things in oneElem, getOneSku() could store things directly into db[db.length].This is maybe not best practice, but if you're leaking memory, it might be a way to solve it.

Link to comment
Share on other sites

Ok, I'm trying to understand. The loadXMLdoc() is locating my xml document, if found and has data, it assigned to the local variable xDoc . So all the information of the xml document is now stored as a single variable. The number of ("sku") elements determines how long the array (db) needs to be. We then call the getOneSku() function created an single object for each ("sku") element. So if there are 8,000 ("sku") elements getOneSku() will create 8,000 objects in the db array? Then the getOneSku() looks at each of the objects data and assigns a property name to it. At this point I can retrieve any of the objects data information by knowing the index number and property name?If I don't assign a property name to each piece of data within each object in the array would this speed things up? Would I then only need to reference the index number and element tag name in order to retrieve the information?

Link to comment
Share on other sites

8000 objects X 20 members each is a lot of data for a browser to chew on. I'm not surprised you're getting the unresponsive script message.And you don't even know how far you're getting before the thing breaks.I would try a simple experiment. Modify this loop so it has an additional line:

for (var i = 0; i < xDoc.getElementsByTagName("sku").length; i++) {	db[db.length] = getOneSku(xDoc, i);	global_index = i; // DO NOT DECLARE THIS AS A VAR}

And somewhere in your HTML, add a button, like this:

<button type="button" onclick="alert(global_index)">Show Index</button>

Now, run your script. After you get the unresponsive message and cancel it, click the button. It will show how far through the 8000 sku's you got. Try it on a fast machine, try it on a slow machine. If you're not getting close to 8000, then you have a problem. Your whole approach to this thing will need to change.I still think working directly with the XML object might be your best choice, rather than copying it into a Javascript object. As you've seen yourself, the DOM routines are ideally suited to pulling data out of XML. Why not take advantage?

Link to comment
Share on other sites

It seems to be going through the entire xml. If I were to take out the getOneSku() function would I still have access to the xml document? Isn't that function really only assigning names to each piece of data? In my xml doc, all of my objects have a member with the tag name of "desc". If I were to remove the getOneSku function, would I reference the xml doc like this xDoc.getElemenstByTagName("desc")and get all the values of "desc"?

Link to comment
Share on other sites

You already have access to the document. Removing the getOneSku() function and the db global would not change that. xDoc.getElementsByTagName("desc")[ i] is exactly the kind of reference you would use to access data in that document. The development of DOM methods is what has made XML a popular means of storing and transmitting information. It's supposed to be easy, not hard. :)I believe that it is up to the browser manufacturer to determine how memory is managed in Javascript, and of course the amount of memory available to manage is up to the individual system. In other words, the standards have to do with operators, available functions, access to the DOM API, and so on -- NOT how it works under the hood.With the HTML DOM, modern browsers should ideally be using the copy-on-demand system of memory management. That is, if you get a reference to the text of some node and assign it to variable x, you are just creating another name for the memory location where the text is stored. You are not creating a copy. If the original value changes, a copy is made at that time, and now x points to the copy instead of the original. If the value never changes, a copy is never made.I don't know if all browsers consistently use the same technique for an XML DOM or not. They should, but it's not my call.But even if they do, simply assigning pointers to 160,000 unique addresses means that a look-up table will have to be accessed that many times without interruption. Not a big deal for a compiled application. Possibly a big deal for a scripted application. Again, I don't know.All we know for sure is that something in this copying technique is requiring a lot of processor time.Except for the occasional infinite loop, the only times I've seen that message are when I'm updating elements that appear on screen. . Like you, I was looping. Specifically, I was creating a few hundred input elements for a spreadsheet application. Not a lot, but drawing is the slowest thing a browser does.But 160,000 lookups . . .The short of this is, YES, you can totally stick to DOM methods to access any part of your XML object on demand. And I think this is the best approach for you, since that is what XML and modern browsers are designed to do.

Link to comment
Share on other sites

The xml doc it is trying to load is very long and will not be this long when the page is published.
I realize that I'm a bit late coming to this conversation, but why on earth is your XML file so large? When I load it in Chrome and view the source, it can only load the first 117,651 lines before it craps out and, based on the scrollbar, it appears to only be showing roughly 2/3 of the file.In the little bit that I'm able to view, I see that your database it split up into "books" which each contain dozens of "skus". Outside of ditching the XML and moving to a database like MySQL or SQLServer, maybe it would make more sense to split up those files, one for each "book". Then you'd only have to scan through hundreds of lines of code per book rather than hundreds of thousands of lines.
Link to comment
Share on other sites

Wow, Jesh, you're right. We so seldom see this kind of thing on this board, I didn't think to look. The first "book" is about 45K. That's pretty huge by itself. Maybe it makes sense to develop a system where AJAX only needs to fetch one book at a time. Some sort of array could keep track of what contents are in what book. Hopefully, the internal organization makes enough sense that a user wouldn't be hopping from one book to the next all the time.Saving the books as individual files sounds like a good step. Otherwise, you'll need a server-side script to open up the file and parse out the required section, and that sounds a bit inefficient.In fact, it might make more sense to keep it all on the server and simply AJAX the individual requests. Even at home, I find that AJAXing a few hundred bytes at a time is pretty snappy.

Link to comment
Share on other sites

Thanks for your help. I created a test page and it works great. I took out the the array, and getOneSku() function.To comment on Jesh's replay, for certain pages elsewhere on my site, separating the xml by book id number makes sense. Like when they want to look at a specific book. To give a little background on our company, we sell fabric and it is organized into over 240 different books and we have over 10,000 different fabrics. The particular page on our website that I am addressing gives our customers the options to select any of our products based on their search criteria. So I need to look at every book we make in order to find every possible fabric they may want to research. In the past we used ASP pages to communicate with our server, but when traffic is high we can see a slowdown internally. We currently use WebWiz to create our dynamic pages which in return runs BASIC programs. WebWiz is not great for developing detailed HTML pages so I am trying to keep all of our data in xml and limit the interaction with our server. To further complicate things, I have no background in WebWiz, ASP, MySQL or Javascript and was given the task three weeks ago of developing these search pages. But I think for now with removing the array (db) and getOneSku() function it has sped up the loading process. It still takes about 2 seconds for the page to load the xml, but I don't think this will frustrate any of our customers. Thanks for your help and if you have any other suggestions please let me know, I am always up for some more help and instructions.

Link to comment
Share on other sites

To further complicate things, I have no background in WebWiz, ASP, MySQL or Javascript and was given the task three weeks ago of developing these search pages.
Well, congrats, you seem to be coming along quickly.Do you currently have control over the generation of your XML file? The current file, according to Firebug, is around 6MB. This is going to take a lot longer than 2 seconds to download if any of your clients are on slower connections. One way to lighten up that file size would be to remove the white-space. For example, each sku has, by my count, 23 properties. Each of those properties is on its own line in the file. Depending on the file system that saved the file, these new lines can be represented by one or two characters which each take up a single byte of data. So, for a single sku block, there are at least 23 bytes of information that the computer doesn't need to process. It doesn't sound like much, but for 10,000 skus in the file, that's 230,000 bytes (224KB) of extraneous data.Instead of:
<sku> <idNum>FORE-1</idNum> <pattern>FORECAST</pattern> ...<Phase>Current</Phase> </sku>

You might consider:

<sku><idNum>FORE-1</idNum><pattern>FORECAST</pattern>...<Phase>Current</Phase></sku>

Also, some of the property names are pretty long. You may or may not be able to do this depending on how far along you are in this project, but the file size could be reduced even further if you shortened some of those names. For example, "construction" could become something like "cxn", "pattern" to "ptn", "patternid" to "ptnid". If you just made those three changes to the property names, you'd go from 28 bytes to 11 bytes. 17 bytes per sku saved is 170,000 extra bytes that your customers wouldn't have to download.If the average length of your properties is, say, 8 characters and you were able to shorten them to an average of 3 characters, that's 5 bytes savings per property at 23 properties is 115 bytes per sku and 1,150,000 bytes (1MB) over the entire document.Again, it all may be moot if you are unable to modify the structure of your XML. In that case, just something to keep in mind for future projects.

Link to comment
Share on other sites

Thanks Jesh. Fortunately I have complete control over the BASIC program that creates the xml document. So instead of creating the properties of each <sku> on a new line, I would make each <sku> and it's properties a single line? I think that reducing the amount of characters for each each property name is a good idea.Thanks for the tip!When I open the xml document in a browser window it looks like a continuous line of all my data. Is this how it looks when the it is loaded into my HTML page? If so, doesn't this take care of all the white space?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...