Is it better to encapsulate functionality in a jQuery plugin or vanilla JavaScript function?

It really depends on the rest of your site. If you are using the rest of the jQuery library, if you are then you can utilise jQuery specific functions inside of your own - each() is a good example. That kind of jQuery magic might allow you to write less code.

I would look into doing some kind of benchmark where you write both and see which one executes faster.

It really depends on the rest of your site. If you are using the rest of the jQuery library, if you are then you can utilise jQuery specific functions inside of your own - each() is a good example. That kind of jQuery magic might allow you to write less code.

I would look into doing some kind of benchmark where you write both and see which one executes faster. But if you want a function that you can move from site to site without dependancies it might be a good idea to go it alone with Javascript. Personally I would be inclined to use plain Javascript so that I wasn't bound down to any 1 library, but that's your choice.

1 I think that he will use jQuery functions in both, I believe he is just asking how its better to "name" functions. – GrizzLy Jul 25 '11 at 13:26 Right, I suppose (depending on performance) it just comes down to personal choice. – Tom Walters Jul 25 '11 at 13:28.

Well, when I do this sort of stuff I use ordinary javascript functions, I think its easier to look up function like that, I don't see downsides with pure javascript, and I see one downside with jQuery. Fn, that is when someone looks at your code and sees $("selector"). SomeFunctionName, he might try searching jquery docs for that function.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions