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
  • 1 View
  • 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 found a nice example on how to use AJAX in jQuery at this
I am trying to use jQuery in a highly conflict environment. .noConflict() doesn't work
Backbone JS highly recommends you use jQuery. However, it doesn't do things very jQuery.
I have a web-based application which is very highly reliant on jquery / javascript,
I'm currently fiddling around with JSON - but I can't get jQuery's $.ajax method
i got a jquery upload and crop script and i am trying to use
I want to use jquery to edit the class margin properties if its on
Out of curiosity I right-clicked on a Javascript function (nested in a highly-called jQuery
I am currently developing a jquery function which I intend to use to replace
http://jquery.com/ provides great controls. And also there are many other opensource control based on

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.