Giter VIP home page Giter VIP logo

example-multipage's Introduction

RequireJS

RequireJS loads plain JavaScript files as well as more defined modules. It is optimized for in-browser use, including in a Web Worker, but it can be used in other JavaScript environments, like Rhino and Node. It implements the Asynchronous Module API.

RequireJS uses plain script tags to load modules/files, so it should allow for easy debugging. It can be used simply to load existing JavaScript files, so you can add it to your existing project without having to re-write your JavaScript files.

RequireJS includes an optimization tool you can run as part of your packaging steps for deploying your code. The optimization tool can combine and minify your JavaScript files to allow for better performance.

If the JavaScript file defines a JavaScript module via define(), then there are other benefits RequireJS can offer: improvements over traditional CommonJS modules and loading multiple versions of a module in a page. RequireJS also has a plugin system that supports features like i18n string bundles, and text file dependencies.

RequireJS does not have any dependencies on a JavaScript framework.

RequireJS works in IE 6+, Firefox 2+, Safari 3.2+, Chrome 3+, and Opera 10+.

Latest Release

License

MIT

Code of Conduct

jQuery Foundation Code of Conduct.

Directories

  • dist: Scripts and assets to generate the requirejs.org docs, and for generating a require.js release.
  • docs: The raw HTML files for the requirejs.org docs. Only includes the body of each page. Files in dist are used to generate a complete HTML page.
  • tests: Tests for require.js.
  • testBaseUrl.js: A file used in the tests inside tests. Purposely placed outside the tests directory for testing paths that go outside a baseUrl.
  • updatesubs.sh: Updates projects that depend on require.js Assumes the projects are siblings to this directory and have specific names. Useful to copy require.js to dependent projects easily while in development.

Tests

This repo assumes some other repos are checked out as siblings to this repo:

git clone https://github.com/requirejs/text.git
git clone https://github.com/requirejs/i18n.git
git clone https://github.com/requirejs/domReady.git
git clone https://github.com/requirejs/requirejs.git

So when the above clones are done, the directory structure should look like:

  • domReady
  • i18n
  • text
  • requirejs (this repo)

You will need to be connected to the internet because the JSONP and remoteUrls tests access the internet to complete their tests.

Serve the directory with these 4 siblings from a web server. It can be a local web server.

Open requirejs/tests/index.html in all the browsers, click the arrow button to run all the tests.

example-multipage's People

Contributors

evverx avatar jrburke avatar pscheit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

example-multipage's Issues

Help minifying js and css in two different files

I have a backbone project with several js files and a couple of css files, and I'd like to have them minified to a single js and a single css.

I created a stackoverflow question with the details of my setup.

http://stackoverflow.com/questions/16901246/how-to-minify-css-files-with-requirejs

Perhaps anybody around here could give me a hand. I think this should be a pretty common scenario.

I had a look at https://github.com/requirejs/example-multipage/blob/master/tools/build.js but couldn't find the correct way to configure my project

Thanks a lot

Multipage build doesn't work

How is it possible to use requirejs.optimizer (node.js) to build each page? I am attempting to run the optimizer but it produces nothing. I believe its failing at parse.findConfig because there is no ObjectExpression representing the require config, just an array in the require that depends on the config.

Is there any way to reduce the config of build ?

Hi there, I have a problem about the build config file.

part of my build.js

  paths: {
    config: 'pages/config',
    module1: 'modules/module1',
    module2: 'modules/module2'
  },
  modules: [
  {
    name: 'pages/page1',
    include: ['module1', 'module2']
  },
  {
    name: 'pages/page2',
    include: ['module2']
  }
  ]

page1.js

require(['config'], function() {
require(['module1', 'module2'], function(m1, m2) {
})
})

page2.js

require(['config'], function() {
require(['module2'], function(m2) {
})
})

Can r.js find the inner dependencies automatically? So I no need to configure the the 'paths' or the 'include'.

Like this

build.js

  paths: {
    config: 'pages/config'
  },
  modules:
  [
  {
    name: 'pages/page1'
  },
  {
    name: 'pages/page2'
  }
  ]

Post-build customization

Hi, I have a question regarding this example.

Let's say I build a multipage webapp with RequireJS as shown here, and ship it to be installed by a user on his own server.

Now how would I implement the possibility for the said user to add some of his own JS code into only page2, and possibly also to the common shared JS between all pages, but WITHOUT having him touch any of the original app code or JS files or rebuild the bundles ?

Could I imaging requiring an additonal page2-custom.js module that would not originally exist, and thus whould not be included in the bundle, and then once the user creates such a file in a pre-defined folder, it would automagically plug into the flow ?

Or another solution if you have one

Thanks a lot

Example when page2 is in a different directory

It'd be nice to see an example if page2.html was served from www/foo/page2.html (with a url path of /foo/page2.html) while page1.html is still served from www/page1.html (with a url path of /page1.html)

Static resource MD5

What solution if CSS image MD5 according to hash JS? The project is the same as your project.

Any way to avoid so much JS files?

Basicly with this setup, each HTML page needs TWO javascript files, pageX.js and mainX.js

Wouldn't there be an elegant way to avoid that and only have one JS per page ?

Thanks

typo in controller/Base.js

I think there is a typo in controller/Base.js, line 12-13:

bodyDom.prepend('<h1>Controller ' + this.id + ' says "' +
                      this.model.getTitle() + '"</h2>');

you may want to change the h1 to h2 or h2 to h1 here.

Is it really multi-page if all pages have to share the same config?

I would like an example where an initial config is loaded, containing 'aspect-oriented' stuff and maybe some jQuery lovelyness. If there is a constant landing page it could include that too.

Then as a page is dynamically loaded, one can dynamically update the dependencies for modules on that page. As a page is loaded, a function that calls require.config would be expected (pseudo interface) to exist like the 'init' in shims.

This will also allow teams to develop 'pages' without having to modify the shared config when a new page is added or as in my case, a third party to develop all the views whilst I do the data api. We have nothing in common except jQuery which I preload then fake the define to keep it out of the config.

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.