I just finished adding a dark theme on this blog, you now can click on a theme switcher (Top left at the page, just below Blogger navigation bar) to switch to dark theme or switch back.

Note

The switcher was removed long time ago. (2015-08-19T02:40:12Z)

I use localStorage to store the theme name instead of in cookie, it’s easier than using cookie. I don’t use another set of stylesheet, I simply run $('body').addClass('Dark'). It’s easy to change theme without worrying residual of other theme styles, clean the class and add new one. I will stay on Dark theme from now on and that’s the whole point I made it.

While I was adding the theme, I noticed this log:

[18:29:28.821] GET http://www.yjl.im/js/highlight.pack.js?_=1297074568808 [HTTP/1.1 200 OK 252ms]

I wonder how much bandwidth I have wasted on my GAE server and others. I use getScript three or more times in my main JavaScript for this blog. A quick search I found a page which re-defines getScripts(), but I use another method from a comment of that page:

// turn on cache
$.ajaxSetup({ cache: true });
$.getScript(url, callback);
// turn cache back off
$.ajaxSetup({ cache: false })

I don’t like re-defining, I call that dirty trick. If it’s not necessary, I don’t use that way. In this case, it’s not but you have to use two additional lines wherever you need to get a script. After I fixed all of those codes, here is the log:

[18:50:41.977] GET http://www.yjl.im/js/highlight.pack.js [HTTP/1.1 304 Not Modified 25ms]