Table of Contents

Keep Organized

Use Source Control

A Template of code document

- Summary
- How to use it in the code
- Discussion

Reference: - WWDC 2019 Great Developer Habbits: https://developer.apple.com/videos/play/wwdc2019/239/

Minimizing Function Footprint

It's good practice when writing plugins to only take up one slot within $.fn. This reduces both the chance that your plugin will be overridden, and the chance that your plugin will override other plugins. In other words, this is bad:

snippet.javascript
(function( $ ) {
 
    $.fn.openPopup = function() {
        // Open popup code.
    };
 
    $.fn.closePopup = function() {
        // Close popup code.
    };
 
}( jQuery ));

It would be much better to have one slot, and use parameters to control what action that one slot performs.

snippet.javascript
(function( $ ) {
 
    $.fn.popup = function( action ) {
 
        if ( action === "open") {
            // Open popup code.
        }
 
        if ( action === "close" ) {
            // Close popup code.
        }
 
    };
 
}( jQuery ));