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

  • Home
  • SEARCH
  • 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 6475591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:43:22+00:00 2026-05-25T06:43:22+00:00

I am trying to dynamically load a jQuery plugin by calling getScript – but

  • 0

I am trying to dynamically load a jQuery plugin by calling “getScript” – but it doesn’t seem to recognize the initialization function of the plugin.

However, if I simply include the plugin by creating a script tag, the plugin works fine. I cannot use a static script tag because the final product is loaded dynamically via JavaScript that is put on a page that I do not have control of.

I’ve demonstrated this below with a plugin called jScrollPane:

The first head is the working copy, and the second is the dynamic way. When the dynamic way is run, there is an error that $(‘#content’).jScrollPane() is not a function!

   <head>
        <link type="text/css" href="http://jscrollpane.kelvinluck.com/style/jquery.jscrollpane.css" rel="stylesheet" media="all" />
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
        <script type="text/javascript" src="http://jscrollpane.kelvinluck.com/script/jquery.mousewheel.js"></script>
        <script type="text/javascript" src="http://jscrollpane.kelvinluck.com/script/mwheelIntent.js"></script>
        <script type="text/javascript" src="http://jscrollpane.kelvinluck.com/script/jquery.jscrollpane.min.js"></script>

    </head>



    <head>
        <link type="text/css" href="http://jscrollpane.kelvinluck.com/style/jquery.jscrollpane.css" rel="stylesheet" media="all" />
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
        <script type="text/javascript" src="http://jscrollpane.kelvinluck.com/script/jquery.mousewheel.js"></script>
        <script type="text/javascript" src="http://jscrollpane.kelvinluck.com/script/mwheelIntent.js"></script>
        <script type="text/javascript">
            function setScroll() {
                $(function () {
                    $('#content').jScrollPane();
                });
            }
        </script>
<script type="text/javascript">
        $.getScript("http://jscrollpane.kelvinluck.com/script/jquery.jscrollpane.min.js", setScroll());
    </script>
</head>

The only thing that has changed is that the jquery.jscrollpane.min.js is being loaded by .getScript and then the actually initialization occurs in the callback function.

  • 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-25T06:43:23+00:00Added an answer on May 25, 2026 at 6:43 am

    You want to pass the setScroll function to getScript, but instead you’re actually calling it and passing whatever it returns. Lose that final ().

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

Sidebar

Related Questions

I'm trying to attach a jQuery plugin to a dynamically generated button. I've tried
I am trying to load a file.js dynamically with $.getScript. I have several select
I'm trying to dynamically define functions that call through to another function that takes
I am trying to dynamically load a JavaScript file by adding a script element
I am trying manipulate Jquery Infinite Carousel into dynamically resizing the image container based
I am trying to load values into a select dynamically using values from a
I'm trying to create a simple ajax load test script that dynamically creates divs,
I'm trying to name the instances of MovieClips that I dynamically load. I tried
I am trying to dynamicaly compile code using CodeDom. I can load other assemblies,
I'm trying to dynamically generate a gif image of a specified size and color

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.