Let's say I have some bit of JavaScript that will modify the DOM, perhaps hide / show the form field or something like that, and let me assume that I want to complete this task on several pages, but only once or twice on page.
Is it better to encapsulate this functionality in a jQuery plugin or vanilla JavaScript function?
Essentially, these are:
jQuery.fn.toggleFormInput = function() {
better or worse than this:
function toggleFormInput () {
javascript jquery jquery-plugins
sfrost2004
source share