Coder Social home page Coder Social logo

Almond timing issue page load about almond HOT 4 CLOSED

requirejs avatar requirejs commented on June 8, 2024
Almond timing issue page load

from almond.

Comments (4)

jrburke avatar jrburke commented on June 8, 2024

It depends on when you load almond, but I can see this happening -- almond executes any require([]) calls inserted by insertRequire after the current spin of the event loop, so if you want the module directly after that require([]) call it will probably not be there.

requirejs will be changed in a future release, requirejs/requirejs#373, to match this behavior, since it is more correct.

So the trick then is to work out the page logic to match that execution model in almond since that will be more future compatible. I did not quite follow the sequence of events in the description. If you have code or code samples that might work better if you want some suggestions on how to construct the code.

Going to close this for now for bug triage, but please feel free to continue the discussion here, and if an issue is uncovered, we can reopen.

from almond.

sowelie avatar sowelie commented on June 8, 2024

Hey John, thanks for the quick response! Also, thank you for your hard work, RequireJS is awesome and it is really helping the development process for me.

What I'm looking to do is basically make the module loading seamless to the end user. I want them to be able to include my bundled JS file (which was built by the RequireJS optimizer) and then as soon as the page load event fires, I want them to be able to access all of the code that was loaded in the bundled JS file.

Is this possible to accomplish with almond? Would it make more sense for the RequireJS optimizer to order the code in the bundle properly and remove the define / require calls (thus completely removing the reliance on an AMD loader)?

from almond.

jrburke avatar jrburke commented on June 8, 2024

almond right now allows synchronous access at the top level require level to modules by doing:

require('foo');

However, this is not portable to other AMD loaders (even requirejs), and is not a standard feature for top-level require() APIs (it can work for local require('') API calls inside modules though).

So if you are OK sticking with almond, then I would probably do something in a wrap.end or wrap.endFile that would expose your code in the global space by using the require('foo') to get the modules.

from almond.

sowelie avatar sowelie commented on June 8, 2024

This seems to work just fine! For this version of my script I will only ever be relying on the AMD module of my choice.

from almond.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.