Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-04-10 02:17:22

squaredeye
Member
From: Greenville, SC
Registered: 2005-07-31
Posts: 1,495
Website

Query Times vs. JS

What kind of difference would one be looking at for these kinds of calls/scripts? Timewise?

The original: (from a form)

<li <txp:zem_nth step=1 of=2>class="odd"</txp:zem_nth>>
<p class="post-date"><txp:posted format="%b/%d/%y" /></p>
<h3 class="post-title"><txp:permlink><txp:title /></txp:permlink></h3>
</li>

The new: also in a form:

<li>
<p class="post-date"><txp:posted format="%b/%d/%y" /></p>
<h3 class="post-title"><txp:permlink><txp:title /></txp:permlink></h3>
</li>

With this in the head:

<script type="text/javascript">
// <![CDATA[
$(document).ready(function() {
	$("ul#tag-list li:nth-child(odd)").addClass("odd");
 });

// ]]>
</script>

Last edited by ma_smith (2007-04-10 02:17:44)


Offline

#2 2007-04-10 04:27:10

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: Query Times vs. JS

Personally, I would go with JS for cleaner source code. Timewise, I don’t know…but Safari can give you an idea. Not sure how much it helps, but here are the instructions:

  1. enable the debug menu
    1. Relaunch and make sure there are no tabs open, or else you’ll get a bizarre error message
  2. ⌘\ (Debug>Show Page Load Test Window)
  3. switch “Suite” to “URL
  4. Enter URL and click start

It might be more precise to test locally too.

As an aside, I would definitely gzip the jQuery library though, since it gains more weight everyday (whatever happened to 16kb?!). Place this at the top of your jquery file (save as .php):

<?php 
	//http://fiftyfoureleven.com/weblog/web-development/css/the-definitive-css-gzip-method
	ob_start ("ob_gzhandler");
	header("Content-type: text/javascript; charset: UTF-8");
	header("Cache-Control: must-revalidate");
	$offset = 60 * 60 ;
	$ExpStr = "Expires: " . 
	gmdate("D, d M Y H:i:s",
	time() + $offset) . " GMT";
	header($ExpStr);
?>

edit: added some images

Last edited by jm (2007-04-10 04:46:03)

Offline

#3 2007-04-10 17:55:43

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: Query Times vs. JS

Offline

#4 2007-04-10 22:10:10

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: Query Times vs. JS

What kind of difference would one be looking at for these kinds of calls/scripts? Timewise?

Textpattern’s ‘Runtime’ output (bottom of page source in Testing mode) will give you a good indication of the the time spent on the server side.

I’d wager that the difference between the two is insignificant on average. Usually the slowest thing on a Textpattern page is the article list tag, which would be the same in both cases. Tags like zem_nth take no time at all compared with tags that perform database queries.


Alex

Offline

#5 2007-04-10 22:29:44

squaredeye
Member
From: Greenville, SC
Registered: 2005-07-31
Posts: 1,495
Website

Re: Query Times vs. JS

All,
thx. This was more an exercise in learning about queries, php, js etc. Very informative. Thnx. Also, Mary. Sorry about the double post. I’ve had that happen twice recently. I’ll look into it.

M


Offline

Board footer

Powered by FluxBB