For a while now, I’ve been trying to think of the best way to get localized strings into Javascript under Plone. Many existing packages and parts of Plone use one Javascript file per language, containing all translations. Whilst this is effective, it doesn’t “feel right” having all your translations distributed to the user on each page load, much less having them drawn from two different sources. Worse still (in my mind) is having translations dumped out into hidden HTML elements and then recalled by Javascript using getElementById or some such.
The solution I’ve eventually settled on is one that combines AJAX and client-side caching in cookies to minimize page load time. The implementation consists of a single view, a Javascript file and a bunch of XML & ZCML to tie it all together.
The powers that be here at Isotoma, have kindly agreed to let me open source this under the Apache 2.0 license.
Full documentation can be found for the code can be found in the README.txt, however I’ve included a quickstart guide below.
Continue reading ‘Javascript localization within Plone’
Best Practices for Speeding Up Your Web Site — part of an excellent series of articles on the Yahoo Developer Network.
They mainly focus on the front end, as that is where you’ll get most bang for your buck. They make frequent reference to YSlow, a Firebug extension that looks extremely useful.
The presentation here is also strongly recommended, as it makes succinct arguments for all the techniques. (View on Slideshare to see it full-screen.)
Some things were familiar to me (and most are already standard practice for my colleagues), many weren’t (e.g. avoid @import for CSS), and some I know of but haven’t been convinced of before (e.g. CSS sprites). I was quite intrigued by this example of CSS sprites in use on Google. (When using CSS sprites, remember to consider their accessibility to screen readers, and don’t use if you want them to print.)
A really interesting blog post from Brendan Eich regarding multithreading in Javascript.
It looks like JS might become the Next Big Language on the server as well as the client, so Brendan’s opinions really really matter. I am very glad to see he’s drinking the right kool aid. He doesn’t want explicit multithreading, and he namechecks Erlang, a language I am rather fond of.
Even more interestingly, he says:
In all the fast yet maintainable MT systems I’ve built or worked on, the key idea (which Will Clinger stated clearly to me over lunch last fall) is to separate the mutable unshared data from the immutable shared data. Do that well, with language and VM support, and threads become what they should be: not an abstraction violator from hell, but a scaling device that can be composed with existing abstractions.
Which is absolutely correct. I wonder if he’s thinking along the lines of Oz which uses these ideas explicitly to provide a quite different multiprogramming mechanism.
The release of MochiKit.Animator feels like quite a major thing here. You can read some comments by Kevin Dangoor and Ajaxian.
It’s a fantastic API, and it really looks and smells far better than Scriptaculous, the current king of the javascript animation space.
What’s really nice about MochiKit.Animation is it’s use of the functional style, which produces terse but expressive source that is often “obviously” right – much better than Object Orientation for a lot of tasks. Seeing this applied so neatly to animation is fantastic.
Quick recommendation for Firebug. Superb!
The public release of Vista and IE7+ looks set to make site developers’ lives even harder; although possibly this time it will be for some right reasons, rather than the usual wrong ones. In trying to get tough on security it looks like Microsoft may have made making your site acceptable, particularly on heavily scripted sites, very hard work indeed.
Fascinating news from Brendan Eich (CTO of Mozilla and creator of Javascript). The first deployment of Javascript 2 is expected by middle of next year and, to quote a piece in PC Welt: For the future, JavaScript will follow Python. “We’re going to learn from Python. JavaScript is pretty close to Python,” Eich said. Python 2.5 is being tracked, he said..
The two languages are natural companions; it really highlights the architectural success of projects like Mochikit and Nevow (and LivePage in particular)
Intro to Mochikit
This is well worth a look on two levels. Firstly it is a fantastic introduction to Mochikit (the Isotoma Javascript library of choice); giving you enough detail to whet your appetite without going overboard. Secondly it’s a fine technical example of what’s possible with Mochikit, Python and reStructuredText!
Recent comments