$.extend ({},defaults, Options)--(First Experience III)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.