JQuery - application code against creating a plugin

When does it make sense to turn your code into a jQuery plugin?

What are the criteria / signs that parts of your code may be better as plugins?

+3
source share
2 answers

In fact, your code is a jQuery plugin as soon as you start adding new stuff to $.fn.

But also, it makes sense to reuse code or code that is not specific to your application.

Also see the Plugin Creation Guide - this shows you some best practices that you should follow; especially if you can release your jQuery plugin at some point. But it may also give you some ideas on when it makes sense to make your code a plugin.

+2
source

This is more than anything else, if the code is completely completely abstracted / can be reused, and if so, if you think you really need to reuse it at any time in the near future. I usually get a mixture of both; general functionality abstracted in plugins, and custom user code that configures these plugins and customizes everything that is unique to this page.

, , , . , , , , . Javascript .

+2

Source: https://habr.com/ru/post/1788432/


All Articles