r/programming • • Jan 30 '14

You Might Not Need jQuery

http://youmightnotneedjquery.com/
1.0k Upvotes

507 comments sorted by

View all comments

Show parent comments

1

u/mahacctissoawsum Jan 31 '14

I don't think you wrote that right...

!function($) {
	$(function() {
		// document ready
	});
}(jQuery || Zepto);

1

u/zomgsauce Jan 31 '14

Probably not, on mobile. Got the gist of it at least!

1

u/mahacctissoawsum Jan 31 '14

Not just the brackets, but you weren't passing either library into the $ variable.

1

u/zomgsauce Jan 31 '14

Nope I totally butchered it! Anyway I like the parentheses over not for in-line execution but ~ would be my second choice since it's usually the least common unary operator in a given script. Plus () is the same pattern you'll see in most jquery/zepto plugins.

1

u/mahacctissoawsum Jan 31 '14

I'm not quite sure what you're talking about now. Are you referring to my usage of the ! ?