Wednesday, July 29, 2009

Importance of trying

I had an experience recently that reinforces a good lesson I think. That being how different it is to learn passively (by reading) versus actively, by trying to use it to accomplish something.

In this case it was attempting to provide the functionality I've been working on the last couple months that sits in an extension to Firefox and implementing it in a bookmarklet.

This first led me to refactor some of the code that I had written for the extension so that it separated out the parts that were specific to the firefox extension from the pieces that were more general and could be leveraged by something else (in this case, in anticipation of use by the bookmarklet).

Then followed learning about how bookmarlets work, common approaches, and the like.

Early use of the bookmarklet was successful, but I ran into a fatal problem. What I'm doing requires access to the entire web page, including all iframes. Because of security concerns, browsers disallow cross-domain javascript access into iframes. Which means essentially that running in the context of launching from a bookmarklet, I don't have enough "power" to do the things I want to do.

So in the end, the whole bookmarklet approach had to be abandoned. But the exercise was a great benefit:

1. The refactor of the javascript code that I already had makes it more flexible and easier to deal with.

2. I learned all about bookmarklets and how they work.

3. I learned more about the internals of the web browser, and specifically the issues around the challenges that cross-domain iframe access presents.

Of course, I would have been happier if the bookmarklet approach had also panned out - but I'll take what I can get.

No comments:

Post a Comment