Coder Social home page Coder Social logo

Comments (3)

jrburke avatar jrburke commented on June 2, 2024

What you mentioned is the way to do it:

<script type="text/javascript">
        require(["common"], function() {
                require(["myApp"], function () {});
        })
</script>

There are no plans to support a data-config attribute on the script tag. It complicates build scenarios and will lead to more support questions on how it actually works. Where having the explicit require calls done avoids those issues.

You could implement that yourself though, by having all pages use a data-main="config.js" and config.js would set the common config, then grab document.getElementsByTagName('script') and look for one that has a data-config attribute on it.

from example-multipage-shim.

mikko-apo avatar mikko-apo commented on June 2, 2024

Thanks for the comments and it's understandable that you don't want to complicate the API.

Anyways, I think it would be good if that solution was added somewhere to the documentation or the example pages. It took some time before we figured out that there was a race condition between loading the data-main config and loading the rest of the required files (since they were loaded in parallel).

from example-multipage-shim.

jrburke avatar jrburke commented on June 2, 2024

One of the goals of this sample repo was to demonstrate that technique, used in the HTML files:
https://github.com/requirejs/example-multipage-shim/blob/master/www/page1.html

The discussion of the problem with data-main is talked about a little bit in the readme, but I do appreciate that there is a lot going on in the readme and there may be a better way to say it.

from example-multipage-shim.

Related Issues (12)

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.