Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1054039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:20:36+00:00 2026-05-16T17:20:36+00:00

jQuery is highly focused on the DOM and provides a nice abstraction around it.

  • 0

jQuery is highly focused on the DOM and provides a nice abstraction around it. In doing so, it makes use of various well known design patterns which just hit me yesterday. One obvious example would be the Decorator pattern. The jQuery object provides new and additional functionality around a regular DOM object.

For example, the DOM has a native insertBefore method but there is no corresponding insertAfter method. There are various implementations available to fill this gap, and jQuery is one such library that provides this functionality:

$(selector).after(..)
$(selector).insertAfter(..)

There are many other examples of the Decorator pattern being heavily used in jQuery.

What other examples, big or small, of design patterns have you noticed that are part of the library itself? Also, please provide an example of the usage of the pattern.

Making this a community wiki as I believe that various things people love about jQuery can be traced back to well known design patterns, just that they are not commonly referred to by the pattern’s name. There is no one answer to this question, but cataloging these patterns will provide a useful insight into the library itself.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T17:20:37+00:00Added an answer on May 16, 2026 at 5:20 pm

    Lazy Initialization:

    $(document).ready(function(){
        $('div.app').myPlugin();
    });
    

    Adapter or wrapper

    $('div').css({
        opacity: .1 // opacity in modern browsers, filter in IE.
    });
    

    Facade

    // higher level interfaces (facades) for $.ajax();
    $.getJSON();
    $.get();
    $.getScript();
    $.post();
    

    Observer

    // jQuery utilizes it's own event system implementation on top of DOM events.
    $('div').click(function(){})
    $('div').trigger('click', function(){})
    

    Iterator

    $.each(function(){});
    $('div').each(function(){});
    

    Strategy

    $('div').toggle(function(){}, function(){});
    

    Proxy

    $.proxy(function(){}, obj); // =oP
    

    Builder

    $('<div class="hello">world</div>');
    

    Prototype

    // this feels like cheating...
    $.fn.plugin = function(){}
    $('div').plugin();
    

    Flyweight

    // CONFIG is shared
    $.fn.plugin = function(CONFIG){
         CONFIG = $.extend({
             content: 'Hello world!'
         }, CONFIG);
         this.html(CONFIG.content);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have run into an issue with JQuery form submissions and have found no
I am trying to learn jQuery and I posted a question asking for some
jQuery Version: 1.4.1 I am attempting to write a simple watermark type plugin and
jquery iphone ui and jqtouch they are lib of iphone , i want to
I am in the process of designing a financial web page (using Java, Wicket,
We've put frustrating hours into the attempt to get a remarkably simple script to
as obviously the css related to the page being injected is not loaded by
I only have about 2 yrs experience of web development under my belt, so
I seem to have exactly the same problem as this person: http://forums.adobe.com/thread/618752 He also

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.