JQuery AMD Plugin Template

    06 Aug 2013

    Several years ago I posted how to write a jquery plugin template, but in the recent years, browser javascript is evolving, developers are more likely using asynchronous module definition API (Require.js). So the jquery plugin template should also be updated like

    (function (factory) {
      if (typeof define === 'function' && define.amd) {
        // AMD. Register as anonymous module.
        define(['jquery'], factory);
      } else {
        // Browser globals.
    }(function ($) {
    Read More


    JQuery Plugin Template

    20 Dec 2010

    JQuery is one of the most important javascript framework I used, besides default jquery apis, I use a lot of jquery plugins to improve the web interactive, such as auto complete, dropdown menu, chart and so on.

    I will be likely to write some jquery plugins or hack others' jquery plugins, The following is the template for a jquery plugin that I learned from "jQuery 1.4 Plugin Development"

    (function($) {
      $.fn.pluginName = function(options) {
        var defaults = {
        var o = ...
    Read More