1.$.extend ({},defaults, options)
This is done to protect the package default parameters. Which is the parameter inside the defaults.
The idea is to have a new empty object ({}) as the first parameter of $.extend, followed by defaults and user-passed parameter objects, and the benefit is that all values are merged into the empty object, protecting the default values inside the plug-in.
function (options) { var defaults = { ' color ': ' Red ', ' fontSize ': ' 12px ' }; var settings = $.extend ({},defaults, options); // make an empty object The first argument return This . css ({ ' color ': Settings.color, ' fontSize ': Settings.fontsize });}
2. Code obfuscation and compression
You download the plug-in, generally will provide a compressed version of the file name usually with a ' min ' word. That's what minified means, condensed version.
Compression here does not refer to the function of the code compression, but by the code inside the variable name, method function name and so on with a shorter name to replace, and delete the comments (if any) to delete the space between the code and the resulting condensed version of the line. At the same time, because the various names in the code have been replaced, others can not read and distinguish their logic, but also play a role in confusing the code.
Advantages of compression: 1. Less code, faster loading speed, improved performance
2. Prevent others from stealing code
$.extend ({},defaults, Options)--(First Experience III)