CEMETECH
Leading The Way To The Future
Login [Register]
Username:
Password:
Autologin:

Don't have an account? Register now to chat, post, use our tools, and much more.
Latest Headlines
Online Users
There are 112 users online: 6 members, 78 guests and 28 bots.
Members: foamy3, hellninjas, Thunderbird336.
Bots: VoilaBot (3), Magpie Crawler (3), VoilaBot (2), Googlebot (19), MSN/Bing (1).
RSS & Social Media
SAX
You must log in to view the SAX chat widget
Author Message
SirCmpwn


Coding Knight


Joined: 06 Feb 2010
Posts: 1477
Location: Colorado Springs

Posted: 10 Aug 2011 03:05:56 pm    Post subject: Site Optimization

Hello,
I see a lot of room for improvement in Cemetech's server load and client loading speed. It loads relatively fast, but you could make it much faster with minimal effort. Here's a couple things you could try:
* You can compress your HTML output with this
* Your CSS has lots of comments in it, and it's separated over many lines. This CSS:

Code:
* {
   /*margin:0;*/
   /*padding:0;*/
   font-family: Verdana, Arial, Helvetica, sans-serif;
   font-size: 12px;
   text-align: left;
}

Could become this CSS with identical functionality and a much smaller size:

Code:
*{font-family:Verdana,Arial,Helvetica,sans-serif;font-size:12px;text-align:left;}

* You can also compress images, which is where you'll see the largest speed gain. I ran the home page through an image compressor and got the combined size of all images down to 75% of their original sizes. Puny PNG will be able to significantly reduce the size of PNG, GIF, and JPG files.
* Reduce the size of your javascript. toggle_display.js could be a lot smaller, for instance. It's first function could go from this:

Code:
function hdr_ref(object)
{
   if (document.getElementById)
   {
      return document.getElementById(object);
   }
   else if (document.all)
   {
      return eval('document.all.' + object);
   }
   else
   {
      return false;
   }
}

to this:

Code:
function hdr_ref(object){if(document.getElementById){return document.getElementById(object)}else if(document.all){return eval('document.all.'+object)}else{return false}}

You can use Javascript Compressor for this.
_________________
Drew "Sir Cmpwn" DeVault
Back to top
comicIDIOT


Guru


Joined: 01 May 2006
Posts: 5106
Location: SFBA, California

Posted: 10 Aug 2011 03:34:33 pm    Post subject:

There's no real gain. The site is coded as such so it's easy to modify. It's easier to read lines of intended code with comments than one line of consolidated code.

Indented code is significantly easier to follow and debug, and thus you'll save time adding and editing functions/features over a consolidated line.

Personally, it helped me code C6M. Knowing what applied to what in the CSS helped me decide if it's something I should included in the mobile site; for the most part it's built from the ground up with influences from Cemetech6.
_________________


-Alex
Back to top
merthsoft


File Archiver


Joined: 09 May 2010
Posts: 2735

Posted: 10 Aug 2011 03:37:13 pm    Post subject:

It might be worth, in the future, to have some sort of deployment pattern, though. So that code is as it is on the editing side, but then once you go to actually deploy the site it runs the CSS and JS through minifiers and such.
_________________
Shaun
Back to top
SirCmpwn


Coding Knight


Joined: 06 Feb 2010
Posts: 1477
Location: Colorado Springs

Posted: 10 Aug 2011 04:03:38 pm    Post subject:

Along the lines of what merthsoft said, a lot of websites have a dev version full of comments and whitespace and such, and a release version that is minified. Google does this, for example.
_________________
Drew "Sir Cmpwn" DeVault
Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55741
Location: Earth, Sol, Milky Way

Posted: 10 Aug 2011 04:14:06 pm    Post subject:

That would be a great idea. Unfortunately, I don't maintain separate dev and production sites for something on this scale, even though it would be a best-practice. You were mentioning things about compressing images to save dozens of killobytes as well?
_________________


Back to top
SirCmpwn


Coding Knight


Joined: 06 Feb 2010
Posts: 1477
Location: Colorado Springs

Posted: 10 Aug 2011 04:15:48 pm    Post subject: Re: Site Optimization

KermMartian wrote:
You were mentioning things about compressing images to save dozens of killobytes as well?


SirCmpwn wrote:

* You can also compress images, which is where you'll see the largest speed gain. I ran the home page through an image compressor and got the combined size of all images down to 75% of their original sizes. Puny PNG will be able to significantly reduce the size of PNG, GIF, and JPG files.

_________________
Drew "Sir Cmpwn" DeVault
Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55741
Location: Earth, Sol, Milky Way

Posted: 10 Aug 2011 04:21:22 pm    Post subject:

Silly me and my failure to read carefully. Thanks for that, I'll definitely give it a try. And I might as well go through and do some stripping of commented-out defunct code in my headers.
_________________


Back to top
SirCmpwn


Coding Knight


Joined: 06 Feb 2010
Posts: 1477
Location: Colorado Springs

Posted: 10 Aug 2011 04:23:26 pm    Post subject:

Good luck, hope it makes a nice difference.
_________________
Drew "Sir Cmpwn" DeVault
Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55741
Location: Earth, Sol, Milky Way

Posted: 10 Aug 2011 04:24:18 pm    Post subject:

SirCmpwn wrote:
Good luck, hope it makes a nice difference.
Cheers, I hope so too. I've gone through and done a lot of optimization in SourceCoder as well, since I'm adding Prizm support.
_________________


Back to top
SirCmpwn


Coding Knight


Joined: 06 Feb 2010
Posts: 1477
Location: Colorado Springs

Posted: 10 Aug 2011 04:26:27 pm    Post subject:

Nice, Prizm support will be especially welcome for me.
Also, you could probably find a good use for ImageMagick and write a script to automatically compress all the images on the server.
_________________
Drew "Sir Cmpwn" DeVault
Back to top
Kllrnohj


/=\ PH34R |\/|3


Joined: 24 May 2005
Posts: 8189

Posted: 10 Aug 2011 11:51:46 pm    Post subject: Re: Site Optimization

SirCmpwn wrote:
* Reduce the size of your javascript. toggle_display.js could be a lot smaller, for instance. It's first function could go from this:

Code:
function hdr_ref(object)
{
   if (document.getElementById)
   {
      return document.getElementById(object);
   }
   else if (document.all)
   {
      return eval('document.all.' + object);
   }
   else
   {
      return false;
   }
}

to this:

Code:
function hdr_ref(object){if(document.getElementById){return document.getElementById(object)}else if(document.all){return eval('document.all.'+object)}else{return false}}

You can use Javascript Compressor for this.


"a lot smaller"? Not really. You are falling into the trap of confusing visual length with file size. Removing all those line breaks saves a whopping 14 bytes and has *zero impact on page load times*.

You are also wasting time "compressing" files that are cached anyway. Don't optimize what isn't the bottleneck.

There are other, far more impactful optimizations available. A big one is using things like sprites to avoid multiple image requests (ditto for combining CSS and JS files together). Number of requests is far more impactful than the size of any particular request.
_________________
There are only two kinds of programming languages: those people always bitch about and those nobody uses. (Bjarne Stroustrup)
Back to top
SirCmpwn


Coding Knight


Joined: 06 Feb 2010
Posts: 1477
Location: Colorado Springs

Posted: 10 Aug 2011 11:54:17 pm    Post subject:

Well, it may save 14 bytes for this function, but there is a lot of Javascript in Cemetech.net's source. It also won't be cached for first time visitors.
_________________
Drew "Sir Cmpwn" DeVault
Back to top
Kllrnohj


/=\ PH34R |\/|3


Joined: 24 May 2005
Posts: 8189

Posted: 10 Aug 2011 11:58:42 pm    Post subject:

SirCmpwn wrote:
It also won't be cached for first time visitors.


Because cemetech has tons of those, right?

Again, don't optimize what isn't a bottleneck.

That said, Kerm should definitely be using some of the minifiers out there, and have a dev/production separation (even if it isn't on a different server)
_________________
There are only two kinds of programming languages: those people always bitch about and those nobody uses. (Bjarne Stroustrup)
Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are GMT - 5 Hours

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© Copyright 2000-2013 Cemetech & Kerm Martian :: Page Execution Time: 0.034268 seconds.