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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:21:39+00:00 2026-05-16T22:21:39+00:00

I am building a custom jQuery plugin for a project I am working on.

  • 0

I am building a custom jQuery plugin for a project I am working on. I want to return an object that is custom to another jQuery plugin…rather than having to make sure that each page that uses my plugin also has this other plugin, is it possible to include it in the actual plugin itself?

Rather than type the following on each page that uses my plugin:

<script type="text/javascript" src="url_to_my_plugin" />
<script type="text/javascript" src="url_to_plugin" />

I wanted to see if there is an option that would allow something like:

(function($) {
          $.include('url_to_plugin');
          //code to implement my plugin
})(jQuery);

Thanks for the suggestion Marko… I may be doing something wrong because the plugin I am referencing is not being recognized. Below is my code:

(function($) {
     var script = document.createElement('script');
     script.type = 'text/javascript';
     script.src = 'jquery.simplemodal.js'; //in same dir as my plugin
     //tried both
     document.body.appendChild(script);
     document.getElementsByTagName('head')[0].appendChild(script);

     $.fn.SUI_CheckProgress = function(options) {
          return this.each(function() {
               var obj = $(this);
               var nDiv = $('<div>');
               nDiv.modal(); //error nDiv.modal() is not a function
               $(obj).append(nDiv);
          }
     };
});

I tried declaring the script both inside and outside of the actual function call (the ideal is for it to happen globally). I verified the code executes correctly if I reference the script in the page I am calling from, however when I remove the reference it fails. Any additional info on programatically adding scripts to a page would be appreciated.

Fixed: My issue was that I was referencing the same directory as the js plugin, however when it’s added to the page it’s outside of that directory.

was

script.src = 'jquery.simplemodal.js';

fixed

script.src = 'js/jquery.simplemodal.js';
  • 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-16T22:21:39+00:00Added an answer on May 16, 2026 at 10:21 pm

    Sure – you can create a new script element and append it to the head.

    var script = document.createElement('script');
    script.src = 'url-to-plugin';
    script.type = 'text/javascript';
    document.getElementsByTagName('head')[0].appendChild(script);
    

    If this doesn’t work, maybe try the method on this page, it’s a slightly different approach using setAttribute.

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

Sidebar

Related Questions

I'm building an ASP.Net MVC website. Rather than have everything in one project, I've
I'm building a custom slideshow for a project written with jQuery. Each slideshow has
I'm creating a custom Java Struts tag that is for building and formatting an
We're building a text templating engine out of a custom HttpModule that replaces tags
I'm a newbie to the jQuery UI plugin and I'm building a demo application
I'm building a custom pulldown menu in jQuery. Now I'd like to set the
Building a comment system with Ajax and JQuery and I want the div the
I have read several documentations about building custom ErrorHandler (by inheriting from IErrorHandler). Unfortunately,
I am building a custom win32 control/widget and would like to change the cursor
I'm building some custom tools to work against a JIRA install, and the exposed

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.