JS Style Guide
For our javascript style guide we follow a style that is already popular and many other developers use to style their code,
Our rules with js writing
Use the library only when you need it
When you want to use libraries like jquery, slick, swiper, etc. make it a habit to use the library (import or require) in a separate file from the main.js file. An Example case is when you want to make a slider using slick which is need jquery and slick itself needs to be like the image below :
Don't forget to reinitialize our js in the main.js file
The image below is an example of wrong library usage
maybe you will think why we have to separate the use of the library even though if it is not separated it can work. this is the answer because our development uses a wordpress environment where there will be several different plugins for each project. if by chance between the plugin and custom code there is the same library. then a conflict will occur which can cause the plugin to be crashed So by separating this library from the main js file, the libraries in the plugin and the libraries in our custom code will run separately and avoid conflicts.
Last updated