Posts tagged as JavaScript

Using GitHub Gists to render source code

I’m curently toying with the idea of using GitHub Gists for all my code snippet rendering here on my site (and perhaps elsewhere).

However, I’m struggling to weigh up the pros and cons, so I’m throwing it open to people for comments.

Pros

  1. The syntax is nicely coloured, in a multitude of languages
  2. GitHub does all the heavy lifting of the colouring and provision of downloadable source
  3. The code doesn’t get mangled by the blog’s HTML editor (in this case, TinyMCE)

Cons

  1. It’s JavaScript-based, so Google won’t index the code
  2. It’s JavaScript-based, so you won’t see the code without JS enabled
  3. Until I find a workaround, page rendering is held up while the browser fetches the script to perform document.writes. And GitHub is not always the fastest at serving the gists

What are people’s thoughts? Are Gists the future, or is there a better solution?

1 comment Posted on 14 April, 2010, in JavaScript

Handling initial display states for jQuery-enhanced pages

When building a jQuery-enhanced site (or using any other JavaScript library, for that matter) I find one of the tasks I use jQuery for is to set the initial display states of various elements on the page.

For instance, you may have some elements that should only be displayed if JavaScript is enabled; and some which should be hidden. But what do you do to avoid the flash of unwanted content which may appear before various libraries load? Here's my solution...

Read more »

6 comments Posted on 26 August, 2009, in JavaScript, jQuery, Quick Tips