Dojo toolkit wrapper

I’ve been finding lately that my simplest blog posts grow the longest tails. So here is one for all you dojo toolkit users or wannabe’s. I started seeing the following in dojo scripts that I hadn’t seen before, and couldn’t find any specific comments about it.

;(function(d,$){ /* your code here */})(dojo, dojo.query)

The leading semicolon is a fudge in case you’re using the build tools and glomming multiple files and the one ahead of yours forgot its trailing semicolon. An extra semicolon won’t hurt anything.
In my world (linux conf files), a leading semicolon often is a comment marker, so even though I know that is not the case in ECMAscript (AKA Javascript), it still caused me to do a double take.

The purpose of the anonymous function is to parameterize dojo and dojo.query so that you can use d to refer to dojo, and the JQuery/prototype style $ as shorthand for queries. That’s all there is to it. It also serves to point up a less used way to both define and call a function all in one bang.

5 comments to Dojo toolkit wrapper

  • I’m not sure this merits inclusion in the toolkit since it makes assumptions about file locations, but works in pretty much all environments:

  • Well… if I found it needed and easy to use, I will add your code to use the options… BTW.. its a good move to create such a cool tool kit..

  • Amazing post.This article was extremely fascinating. I am sincerely admiring your capability to respond in a short time with such constructive advices. We shall be eagerly waiting around. Thanks again.

  • abubrorgo

    [color=#365da0][b]Hiya. This may be a great web portal, I am just totally joyful I at last revealed this seeing that I had been on the search for this for an incredibly long time.I’m just gonna introduce myself quickly. I am just thirty seven yr old additionally I am working as some sort of diver. I actually enjoy to play game titles as Space Harrier II and additionally participate in physical activities as archery.My current interest concerns Income infuser review. I studied an enjoyable site regarding this that pointed out: Every single thirty day period users will get a refreshing unique user generated content merchandise to present, as well as every single sewn of promoting materials they have to allow it to become change including nutty.Many they should complete is present readers for the opt-in webpage, sit down just as before and search at the process develop their own venture. Plus the reality that they can have innovative subject material to market every 4 weeks not simply develops his or her profits but tends to make for your great keep impose having a great deal more unaggressive profits in your wallet just about every four week period. I don’t know whether this type of info is correct but it really really helped me regarding[/b][/color] [url=–13643.html]income infuser review[/url][color=#365da0][b].I am most likely to waste a lot of time on this web site and I think I’m going to obtain a lot of thrilling advice. Lets hope I’ll also contribute to the information available on this website. Enjoy yourself everybody, thanks for this very warm greet!!![/b][/color]

A sample text widget

Etiam pulvinar consectetur dolor sed malesuada. Ut convallis euismod dolor nec pretium. Nunc ut tristique massa.

Nam sodales mi vitae dolor ullamcorper et vulputate enim accumsan. Morbi orci magna, tincidunt vitae molestie nec, molestie at mi. Nulla nulla lorem, suscipit in posuere in, interdum non magna.