3

There have being several threads already about how to prettify code when displaying it on blogspot: How to use prettify with blogger/blogspot? and What are the steps I need to take to add nice java code formatting to my blogger/blogspot blog?.

I have tried google's prettify http://code.google.com/p/google-code-prettify/ and syntaxhighlighter http://alexgorbatchev.com/SyntaxHighlighter/. Both are nice. However, I am interested in which has the better performance of both - this is where this thread differs.

Compression

YSlow is telling me neither is being sent compressed to my browser. However, I am not hosting the site myself, I am using google's blogspot for hosting. So, I don't think there is a lot I can do here. Correct?

Cache Both Google's prettify and syntaxhighlighter use javascript files and stylesheets. They host them on a google server and amazon server respectively. if I was hosting files myself I could make use an Apache Http Server and set cache headers on HTTP responses so that returning users don't keep downloading them. If I am not hosting myself and making use of blogspot's free hosting there's nothing I can do, correct?

Server ping time This is a bit a of noddy test. When I ping google's prettify, I get:

Pinging googlecode.l.google.com [209.85.143.82] with 32 bytes of data:
Reply from 209.85.143.82: bytes=32 time=5ms TTL=53
Reply from 209.85.143.82: bytes=32 time=4ms TTL=53
Reply from 209.85.143.82: bytes=32 time=4ms TTL=53
Reply from 209.85.143.82: bytes=32 time=5ms TTL=53

When I ping syntaxhighlighter:

Pinging www.alexgorbatchev.com [69.163.149.228] with 32 bytes of data:
Reply from 69.163.149.228: bytes=32 time=148ms TTL=47
Reply from 69.163.149.228: bytes=32 time=146ms TTL=47
Reply from 69.163.149.228: bytes=32 time=146ms TTL=47
Reply from 69.163.149.228: bytes=32 time=146ms TTL=47

So look's like google's winning this one. Probably using a CDN where I don't think syntaxhighlighter is.

Fewer Http requests

There's a difference of approaches here. Syntaxhighlighter is quite modular with different javascript files for different languages. Google;s prettify using one bigger javascript file. So possible to have a smaller filesize with syntax highlighter if you are including snippets from various languages, you'll of course have more http requests.

So that's the background. The question is what is your performance tip regarding using syntaxhiglighter or google's prettify? How could you make either go faster or ascertain one is faster than the other?

Thanks.

Community
  • 1
  • 1
dublintech
  • 16,815
  • 29
  • 84
  • 115

1 Answers1

5

I think you should go with google(hosted by them) for a couple of reasons:

  1. If the code is hosted by the google url, the browser has a chance of reading from the cache if a website they visited before(not yours) used that same url. This means they could be reading from cache before they even visit your site.

  2. Google has a CDN, this means that they can provide the file from a server which is closest to the requestor. eg. your server may be hosted in the US, but if an Aussie went to your site he still has to go to america to get your files,... not the case with google.

  3. Its cheaper and less hassle for you.

  4. Less HTTP requests is the unsung hero of browser preformance boosting

In terms of google not compressing the files. I have a general rule when coding or doing anything google related:

"Google is smarter than you"

If I think google is not sending compressed files, its either:

  1. I am wrong and google is sending me compressed files

  2. It is best not to send compressed files

  3. Some unknown reason that that is beyond me

Keep it simple bro, trust in the googs

Roderick Obrist
  • 3,688
  • 1
  • 16
  • 17
  • 1
    Too biased answer... This guy must be a hardcore google fan. Amazon also has cdn and great cloud infrastructure. What are your odds against Amazon here? – WarFox Jul 02 '12 at 10:53
  • I know absolutely nothing about Amazon, I'm Australian... over here its just an on line bookstore. And wether I am a fanboy or not, it does not change the fact that Google have the smartest engineers in the world – Roderick Obrist Jul 14 '12 at 01:37
  • 1
    Broaden your knowledge mate. Amazon has one of the finest cloud infrastructure. Have a look at Amazon Web services http://aws.amazon.com/. And as an answer to the question, javascript performance do depend on the script loading time, so it is best to go with faster loading script. But as syntaxhighlighter is very popular, most users will have the script in their browser cache, so it doesn't require an http request, in most cases – WarFox Jul 16 '12 at 09:50