Comments (3)
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.
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.
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)
- Error when compiling with java HOT 2
- enforceDefine = true causes issues HOT 1
- Optimisation
- Any reason not to bundle require.js with common.js? HOT 1
- require&requirejs
- Remove page1.js and page2.js in favor of script tags? HOT 3
- Clarify common.js as shared.js HOT 1
- Reusing a Require.js shim config between pages HOT 1
- Issue with Shim not always loading dependencies HOT 1
- Multi-page app + Backbone + Require...is it worth it? HOT 1
- Dynamic plugins loading HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from example-multipage-shim.