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 8180887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:20:40+00:00 2026-06-07T00:20:40+00:00

Superfish JS is here . Here’s the relevant code: $.fn.extend({ hideSuperfishUl : function() {

  • 0

Superfish JS is here.

Here’s the relevant code:

$.fn.extend({
    hideSuperfishUl : function() {
        // ...code here...
        return this;
    },
    showSuperfishUl : function(){
        // ...code here...
        return this;
    }
});

Questions:

Does $.fn.extend({...}); allow users to override hideSuperfishUl & showSuperfishUl functions? If so, what does the syntax look like to change these methods when calling the plugin:

<script> 

    $(document).ready(function() { 
        $('ul.sf-menu').superfish(); // How to override hideSuperfishUl &/or showSuperfishUl?
    }); 

</script>

Superfish was written a while back… Is this still the best way to allow users to override plugin functionality functions/methods/other? If not, is there a “best” way?

  • 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-06-07T00:20:42+00:00Added an answer on June 7, 2026 at 12:20 am

    Going to try to answer my own question here… Please correct me if anything I write below is wrong! 😉


    This article says this:

    Extend

    In my opinion, this is the least idiomatic way to create a jQuery
    plugin. It uses the jQuery.fn.extend method instead of
    jQuery.fn.pluginName:

    (function($){
      $.fn.extend({
          myPlugin: function() {
              return this.each(function(){
                  // do something
              });
          },
          myOtherPlugin: function() {
              return this.each(function() {
                  // do something
              });
          }
      });
    })(jQuery);
    

    You will find this structure helpful if you need to add a large number
    of plugin methods to jQuery. I would contend, however, that if your
    plugin needs to add that many methods, there may be a better way to
    structure its implementation.

    I feel the extend method is used more by programmers transitioning
    from other JS libraries. I personally find the simple $.fn.pluginName
    =
    structure to be easier to read, and more in line with what you will normally see in jQuery plugins.

    The Superfish JS is using the same code found in the above quote; long story short, showSuperfishUl() and hideSuperfishUl() are additional plugins in the jQuery $.fn namespace.

    I was able to override said functions like so:

    jQuery(function(){
    
        $.fn.showSuperfishUl = function() {
            console.log('OMG');
            return this;
        };
    
        $.fn.hideSuperfishUl = function() {
            console.log('BECKY');
            return this;
        };
    
        jQuery('ul.sf-menu').superfish();
    });
    

    Next, this article says:

    Provide public access to secondary functions as applicable

    // plugin definition
    $.fn.hilight = function(options) {
      // iterate and reformat each matched element
      return this.each(function() {
          var $this = $(this);
          // ...
          var markup = $this.html();
          // call our format function
          markup = $.fn.hilight.format(markup);
          $this.html(markup);
      });
    };
    // define our format function
    $.fn.hilight.format = function(txt) {
      return '<strong>' + txt + '</strong>';
    };
    

    We could have just as easily supported another property on the options
    object that allowed a callback function to be provided to override the
    default formatting. That’s another excellent way to support
    customization of your plugin. The technique shown here takes this a
    step further by actually exposing the format function so that it can
    be redefined. With this technique it would be possible for others to
    ship their own custom overrides of your plugin נin other words, it
    means others can write plugins for your plugin.

    Conclusion:

    Both $.fn.extend and $.fn.pluginName.function are similar and allow the end user to easily override functionality; the former adds new plugins to the jQuery $.fn namespace, whereas the latter are functions which are contained within a single $.fn.pluginName namespace.

    Summary and Best Practices says:

    Don’t clutter the jQuery.fn object with more than one namespace per
    plugin.

    … therefore, my pick for “best” technique is $.fn.pluginName.function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I reduced the font size of a superfish menu using this code .sf-menu a
I am using the superfish menu from this example: http://users.tpg.com.au/j_birch/plugins/superfish/#examples (with Supersubs). It works
What's the difference between using this jQuery(function(){ jQuery('ul.sf-menu').superfish(); }); and just using this? jQuery('ul.sf-menu').superfish();
I am useing the superfish jquery plugin If you view the superfish menu here:
I am using the superfish plugin for jquery here: clicky it works fine in
All, I've got the following code: $(document).ready(function() { // more code using $ as
This code is throwing the following error in IE, but not in any other
I know Suckerfish does this very well, but I don't like the javascript in
I have menu made with Superfish jquery plugin http://users.tpg.com.au/j_birch/plugins/superfish But i have some problems
How would I compact this jQuery drop down menu code? I know you can

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.