Home

Advertisement

Customize

Sep. 16th, 2008

Kolb Consulting / Dygel.Net

On Google Chrome and Javascript

By now you should probably be aware that Google dropped a new browser on the market a couple weeks ago: Chrome. It's currently a beta product (version 0.2 and change) for Windows only, but it already seeing at least the active market share of Apple's Safari in the wild. Google Chrome is worth talking about not just for what features it does and doesn't bring to the browser market or its standards adherence. It's something worth talking about because it's not just Yet Another Web Browser from a code perspective.

I say this and mean it both as a good thing and as something that makes our jobs as web developers harder. And I say 'harder' in the sense that it will force us to not be lazy. Google Chrome changes how back-end browser processing works. For instance, each tab in the browser is its own system process, which optimizes memory recovery over a prolonged period of web use. More importantly, however, is that it changes how Javascript is processed.

For the last fifteen years (or however long Javascript’s been implemented on the browser level), Javascript has been a lock-step affair. Your document is read by the browser vertically. When a <script> block is encountered, its contents are executed, preventing the browser from taking any other action. That is not the case with Google Chrome. I’ve not got it entirely worked out yet, but it is definitely doing more things in parallel, including loading and processing of Javascript.

I'm not speaking for the rest of you, but one habit I've got with my web development is that I will pepper inline <script> tags throught my code. Usually, this is so relevant bits of Javascript remain in the same vascinity as the markup it drives. It might not be entirely proper, but it gets the job done and doesn't make a follow-up developer hunt for unmarried segments of ColdFusion/PHP and Javascript.

This fast-and-loose style of javascript programming has proven to be problematic in Chrome thus far. For instance, in the project I'm currently working on, I'm using Adobe's Spry as an effects and AJAX library in conjunction with ColdFusion's javascript libraries. The Spry includes create the global Spry object and I've had inline <script> blocks that would instantiate Spry effects or data sets. The issue that I was seeing in Chrome is that the inline blocks were sometimes being executed prior to the completion of the Spry includes, resulting in errors from invoking undefined properties of the global Spry.

Thus far, my solution to it has been to revisit the loose bits of inline javascript that I'm so used to peppering throughout our code. If you find yourself in a situation where Google Chrome is making your Javascript go busto, try this at a very early stage of processing.

window.onloadFuncs = [];

// Adds a function to the end of the onload queue.
window.appendOnload = function(func) {
if (func && typeof func == ‘function’) {
window.onloadFuncs.push(func);
}
}

// Adds a function to the beginning of the onload queue.
window.prependOnload = function(func) {
if (func && typeof func == 'function') {
window.onloadFuncs.unshift(func);
}
}

// Executes queued onload functions.
window.onload = function() {
while (window.onloadFuncs.length > 0) {
var func = window.onloadFuncs.shift();
if (func && typeof func == 'function') {
func.call();
}
}
}

Then, you can do this with your inline stuff:

window.appendOnload(function() {
// Do your inline scripting here.
});

This is going to give you control over all the little bits of JS you want to pepper into your document at will and will make sure it's all executed at onLoad (by which point all referenced Javascript files have been executed) in the order you want them executed. It also has the added bonus of meaning you never ever have to write an onload function that has to substitute some other onload.

Hope this helps.

Jan. 31st, 2007

Norway Icon

Vista

Tell me what you know, what you think about Windows Vista. As you might have heard, I have a new computer from Dell, courtesy of Kristen for Christmas, that replaces the machine I built in 2000 and have maintained until this past December. At the time of purchase, Dell was offering a free digital (no media) upgrade to Vista. So I have the option to upgrade, I only have to choose if and when I want to exercise it.

I've been treading water in an ocean of fact an opinion regarding this operating system. I've read a number of things about it that I'm very interested in. DX10 is, of course, an attractive point. Moreover, I think MS is smart to make it friendly with the X360 platform and associated faculties.

There's a lot out there about what's bad or risky or uncertain with the OS. I'm not well versed enough in the material to know how much is baseless flak and how much is hard fact.

Should I decide to go with it, I'd definitely wait at least a couple weeks. Installing a brand new product of this magnitude this early on always spells trouble.
Norway Icon

Frustration

1.) Microsoft Internet Explorer 7
One of the components I've written for eGov's clerk suite is a miscellaneous receipt processor. Receipts in general consist of the subtotal from the items found thereupon plus the taxes and fees and assorted whatnot heaped on top of that. In this instance, receipt items are based on service codes. For a clerk's office, these codes are tied to how the money collected for an item should break down into their general ledger distributions. In other words, when you pay $X to your county clerk for Some License, $W is kept by the clerk's office, $Y goes to the state, and $Z goes back to the county in general (where $W + $Y + $Z = $X).

Not all receipt codes are created equal. Fixed values are trivial, but some of these codes are percentages of a given amount. For instance, if they're charging you for 5% sales tax on your car then the amount you pay rather depends on the amount you paid for your car. So, to proceed with the calculations at that point, my code uses JS' prompt() function to obtain that foreign value immediately rather than muck about running absurd calculations.

Enter MSIE7. Some genius at MS decided that JS' prompt() is an untrusted function call. This means that prompt() does nothing unless one of two things happens:
    1.) The user right-clicks the pop-down sheet each time and chooses to temporarily allow the call to work.
    2.) The site is manually added to MSIE's list of trusted sites.

This came to my attention when I went to train the first end users with this particular component yesterday and it just wasn't working, despite a thorough double-check of functionality. Problem is, I've got MSIE6 on my work computer, which didn't present this asinine problem.

Regarding #1: no one sees those pop-down sheets to begin with ever, let alone the fact that it's a totally unacceptable non-solution to the problem. I cannot count to you the number of PEBKACs I've dealt with that would have been thirty second calls if anyone actually mentioned these sheets to me. Regarding #2: that's something that hasn't been part of our setup process and with counties on the other end of the state it's not a trivial matter to have that arranged.

Ultimately, I'm going to have to write an AJAX-y circumvention that does the same fucking thing as Javascript's prompt() because Microsoft had to go screw with their implementation of JS.

And before you fucking say it, we can't dump MSIE. It's not even an option at TNII counties (it will be uninstalled), let alone the fact that we're using a third-party ActiveX control for dialogless printing.

2.) Apple iPod

Prognosis on my older 20GB model comes and goes. Last night, the thing was a brick. Right now it's "fine". At least, for definitions of fine that are permissive of potential bad clusters on the disk, unexplained and only periodically reproducable startup failures, and so forth.

The way I figure, it's had a run of a few years and it's pretty much enjoying its last days. Time to start looking for a new one, right?

Guess not.

I haven't followed the market for these things avidly or anything. I'm not the kind of guy who gets a boner over the gadget market. Don't get me wrong, gadgets are great and all; I just don't pay much attention until I'm actually in the market.

Apparently, Apple's decided that they really just hate their customers these days. The least expensive iPod model is $250. Sure, the iPod Nanos are cheaper, but I don't want a fucking iPod Nano. Those things have something like 2-8GB of space. I'm using about 15G of my 20GB right now, so that's not even a viable option for me.

Thing is, I can't get an iPod that doesn't have all these new features that I don't want. The whole video kick is nice, but I fly maybe once a year and when I do I've got a book handy. Aside from that, when is a video screen on my iPod going to do me any good. Hell, I don't even need a color screen on mine.

I want what I've got - a 20ish GB MP3 player that integrates directly with iTunes. The product I describe no longer exists on the market. I would gladly give Apple money for the product I want. I will not give Apple money for features I don't want and will not use. This is an impasse, so they're losing me as a customer.

And you'd better believe that this fuck up makes me rethink ever putting money into their desktop or laptop computers, something I've been contemplating for a while.

Oct. 17th, 2006

Norway Icon

(no subject)

I've successfully rebuilt this machine. This time around, I'm planning on keeping the box pretty clean. Historically, I would load my home workstation up with all manner of software. I really don't need that much software sitting on my box, these days. The biggest culprit was customization software -- icons, desktop stuff, you name it. I don't much care for any of that now so to hell with it.

In other news, GameTap is pretty cool. The new Sam & Max is actually out tomorrow, according to them, but I've spent some time fiddling around with it tonight. Right now, I've got Zork: Grand Inquisitor (a game I've misplaced, but have wanted to replay it lately) downloading. I played some Bubble Bobble and Bust A Move while checking it out. There's a lot of selection there. Once I've had my fill of Z:GI, I mean to check out the first couple of Splinter Cell games. Don't want too much downloading at once, per the above.

In other news, I'm running Internet Explorer 7 RC1 on the rebuilt machine. I got tired of Firefox's overhead -- I'd alt+tab from another application and have to wait for it to redraw all its interface widgets. I'm hoping that a more native solution won't be so system intensive.

Oct. 16th, 2006

Norway Icon

(no subject)

Reformatting my workstation today. I got tired of it being a pain in the ass. What does Windows teach us about what to do when the going gets tough? That's right: start over.

Actually, I've been very frustrated very recently by ATI. Apparently, I haven't been running the actual Catalyst drivers for the last 10 months -- just the Windows' make-it-go Plug and Play drivers. The reason I haven't been using Catalyst is because the install process inexplicably fails without notice on any version. Clearly, there's some kind of software conflict there. I didn't realize ATI's failure to not suck until I signed up for Gametap over the weekend (courtesy of Coca Cola).

Those of you in the know might be aware of a little company by the name of Telltale Games. They developed and published the recent graphic adventure based on the Bone graphic novels. I tinkered with it some -- looked like it could be pretty solid. Thing is, their distribution method was crud. Digital distribution with no muscle behind it. Probably could have gone a lot farther than it did if they had some power behind it.

On the heels of the Bone graphic adventure, Telltale bagged the rights to LucasArts' Sam & Max. This time around, they hooked up with Gametap as the distribution method for an episodic Sam & Max franchise. The first installment is due out 1 November.

Long story short, I signed up and the software didn't work thanks to a complete lack of advanced drivers for my ATI card. After spending some quality time on the phone with someone with ATI earlier (any by quality, I more accurately mean wasted), I decided to head my software woes off at the pass and start over.

It's all well and good, anyway. What I use a computer for at home is a lot different now than it was two years ago. I really don't care a whole lot about customization anymore. I suppose it's not that I don't care anymore as much as it is that I don't care enough to merit the effort for it. Plus, it's good to feel like you've got a clean system once in a while.

By the way, Apple released iTunes 7.0.1 a couple weeks ago -- that cleared up the issue with it sucking.

Sep. 15th, 2006

Norway Icon

Urgent iTunes Notice

If you use iTunes, please heed this advice: DO NOT UPGRADE TO VERSION 7.0 OF iTUNES!

Version 7.0 has been changed in such a way that if it cannot monopolize your CPU, your music will sound like crap. For instance, while playing Warcraft, forget about listening to iTunes. Your music will be pain for your ears. It even started skipping when I opened semagic to make this post. Even folks who have machines much newer than mine ([info]voodoo_prophet) are having problems with it. I strongly urge you to NOT upgrade until they fix this crap.

May. 12th, 2005

Norway Icon

Notable Software Updates

Released today: iTunes v4.8.0.31 and Firefox v1.0.4. The former is a point upgrade, but there doesn't seem to be a lot of new functionality. New Music Store features and the ability to transfer contacts and calendars to your iPod with it. No rush there. The latter patches a critical exploit in Firefox 1.0.3, so make no delay in upgrading that one..
Tags:

Advertisement

Customize