2 minute read
Sometimes I catch a tweet out of the corner of my eye and feel a need to comment back and sometimes 140 characters isn’t really enough for me to fulminate with.
Well, yes, but maybe no.
If the only thing you’re loading jQuery and SPServices for is to get the current user’s identity, then it may well be overkill. It’s sort of like using a Dremel tool when all you needed was a Phillips screwdriver. The $().SPServices.SPGetCurrentUser() function certainly makes it easy to get what you need. There are other options on most pages, of course, assuming that you haven’t done too much customization.
The other point I wanted to make is that the two .js files aren ‘t going over the wire every time the page loads. If you use jQuery and/or SPServices to any degree already, they will be cached in the user’s browser, so there’s no download required after the first (unless the cache is clear one way or another). Yes, the browser still has to load and interpret that 88k (I think that Roland was probably looking at jQuery v1.4.4 and SPServices v0.5.8), but again, it’s a really simple way to get information about the current user. It’s surprisingly hard to find out much more than the user’s name with out the trick that I use in $().SPServices.SPGetCurrentUser() (thanks to Einar Otto Stangvik for the original idea!). One would think that knowing the current user would be a very common requirement client-side, but I was amazed that there wasn’t a CurrentUser Web Service or something once I really started digging into things.
So, yes, using jQuery and SPServices may be overkill just to be able to say “Hi, [yournamehere]”. On the other hand, it works, and it works all the time. As with anything you develop, there’s a requirement to engage brain before coding, so don’t forget to do so on little stuff like this, just like with the big stuff.