You are correct in that jQuery doesn't re-query the DOM for elements on each call, but what it does do is re-loop through it's internal cached collection to apply these CSS rules. The perf hit isn't noticeable when jQuery's selection (internal collection) is small. Imagine a webpage with lots of elements you want to select and then want to interact with... that is what I am trying to bring attention to.
Nice point about the object loop. I would image though that the object would have relatively few properties whereas the number of DOM elements in the jQuery collection could vary dramatically based on the UI (think a long list of list items).
I find TypeScript to be an exciting new take on the language. I look forward to using it more this year. Thanks for your post and your PluralSight course
yeah, and the feelings often are true no matter how many times you've upgraded in the past... especially the fear and possibly the anger, but hopefully happy ;)
Yeah mockjax is a great library as well. I usually recommend people added mockjax to existing projects, but if it is a new project recommend using amplify.request. The amplify.request piece enables you to do some things you can't easily with mockjax. For example, amplify.request allows you to change the caching strategy in the define statements and not where the request is being made. Also if the data from the server changes you can add a decoder to the define statement to map the data to what your code expects. Or if the data going out changes you can add a dataMap to the define statement to so your main application code doesn't have to change. You can also create a custom request type other than jQuery AJAX (think maybe websockets or Dojo's ajax). I sometimes use mockjax also in a jsFiddle or demo code where I don't want to get into amplify.request and just want to use out of the box jQuery.ajax. Thanks for your comment.
You have a good point. There is a huge TextMate community from the Mac world and for those that aren't as familiar should hopefully be intrigued by the title. I was trying to go for a short title, but it is already quite long as it is. I may consider changing it... thanks for the suggestion
The example was to show how you could do it, not necessarily that it was needed for that case. However, you might be surprised how many developers aren't familiar with that example regex.
Yeah, my guess is that CoffeeScript took direction from those languages for this feature.
Nice function to convert annotated string to a regex. I wonder if this is being considered in the next versions of JavaScript? Or better yet... native annotation?
I like the CoffeeScript approach since that logic is done at compile time and not when it is being executed.
True, but then you have the overhead of string concatenation... although in the large scheme of things that is probably very small, unless you are doing it in a huge loop, but then you'd cache that RegExp anyway.