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.


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

I use localStorage to store the theme name instead of in cookie, its easier than using cookie. I dont use another set of stylesheet, I simply run $('body').addClass('Dark'). Its 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 thats 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 dont like re-defining, I call that dirty trick. If its not necessary, I dont use that way. In this case, its 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]