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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:32:00+00:00 2026-06-14T03:32:00+00:00

I am working with Chris Imrie’s iteration of RequireJS for ExpressionEngine making all my

  • 0

I am working with Chris Imrie’s iteration of RequireJS for ExpressionEngine making all my fieldtypes compatible. One thing I don’t understand is how to call the functions that are defined in RequireJS.

https://github.com/ckimrie/RequireJS-for-EE

Here is a basic example of what I am trying to do…

var loadImage = function() {
    console.log('loaded');
}

define(function () {
    return loadImage;
});

How do I actually access the loadImage function? My code worked 100%, but when I started using RequireJS, the libraries behave differently. Below is a snippet from a library I am using, it’s completely forked for RequireJS. If I delete the fork and use the standard jQuery call, it works without issue (even with RequireJS loading all the scripts).

Does not work:

if (typeof define === 'function' && define.amd) {
    define(function () {
        return loadImage;
    });
} else {
    $.loadImage = loadImage;
}

Does Work

$.loadImage = loadImage;

Why would jQuery libraries fork the code like this? I am concerned I am overlooking something simple, but given the context that all this code is with ExpressionEngine Fieldtypes, I don’t have a problem altering the libraries.

  • 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-14T03:32:01+00:00Added an answer on June 14, 2026 at 3:32 am

    Apologies for the answer above, I think I understand now what you are trying to do. Basically that library you are referring to (Javascript-Load-Image) has implemented AMD support (the define function you referred to) into their library and you are looking to use it in your own scripts?

    RequireJS can be confusing sometimes because it is capable of loading normal scripts but also AMD JS modules. If you have a JS file that contains a JS constructor or function you are looking to make available as an module to be used by other parts of your code, its as simple as adding the define() call you mentioned above. The important part is that you need to ensure it is requested by RequireJS as an AMD module, otherwise it wont have a module name. This is as simple as omitting the “.js”.

    So as the example above:

    //In your script that needs the loadimage library you would load it by 
    //specifying the path to the JS file and omitting the ".js" extension
    require(["path/to/loadimage"], function(loadimage){
        loadimage();
    });
    
    
    //If you KNOW that the library has already been loaded by RequireJS
    //you can fetch it synchronously from RequireJS' memory by specifying 
    //its path without the .js
    var loadimage = require("path/to/loadimage");
    loadimage()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on one of big project.so that's why my application contains a
First of all, thanks for taking the time to read this. I've been working
I am working through Chris Pine's Ruby book, and I am slightly confused why
Hey all, i was re-working my android app to use OpenGL instead of canvas
Working on a small game using an HTML5 canvas, and javascript. And it's working
Working with an undisclosed API, I found a function that can set the number
Working with Reporting Services 2008 r2. So here's my issue: We have 5 reports
Working with H2 I get this error when I try to write a row
Working on the problems on Project Euler to try to learn Clojure. I'm on
Working with MS Access for the first time and coming across a few problems

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.