Wednesday, August 22, 2007

Jesse Liberty - Silverlight Geek


Question: What is in Silverlight.js? (really)

Question: Where is the magic?  Answer: The plug-in.

 First, what is in Silverlight.js.  That one is easy; you can open it up; it is a text file. You'll notice that it is not easy to read. Conspiracy theorists will posit that this is to discourage you from deconstructing it, but let's face it; we could have made it a lot harder. Nope, it is the way it is to make it incredibly efficient for the browser. If you want to deconstruct, it is painfully easy; put it in word, do a search and replace replacing semicolon with semicolon/newline, and then replace variable names like a and b with something more meaningful.

What you find, no surprise, is that one of the main jobs of Silverlight.js is to (a) see if you have the right plug-in on your machine and if not offer you the opportunity to download it and (b) set the code so that the plug in for your OS and browser is used.  Nothing very special and you can safely ignore this file once you've satisfied your curiosity.

The one thing to remember is that if you build your application and test it and it asks you to download the plug-in, the first thing to check is whether you have the right version of Silverlight.js. Remember, also, that (at least for now), Silverlight 1.0 is self-updating but Silverlight 1.1 is not.

The second question is about the plug-in. When you are developing an application you do not see the plug-in. It does not show up in your list of files in your project. While you cannot step into the plug-in's code, you can double click on the plug-in (e.g., in the handleLoad function) and drag it into the watch window, where you can easily see its methods, events and properties. It makes for fascinating reading and a good adjunct to the Silverlight help files.

Source: Jesse Liberty - Silverlight Geek

No comments: