Re: [requirejs] single page with html and javascript

Showing 1-1 of 1 messages
Re: [requirejs] single page with html and javascript James Burke 6/10/13 2:15 PM
You can include require.js in the source bundle, see the "requireLib"
use in the second example in this section:
http://requirejs.org/docs/optimization.html#onejs

That said, if the goal is to have it all in one file, then including
require.js is likely overkill, and a smaller AMD API provider, like
almond is suggested instead:
https://github.com/jrburke/almond

For CSS or things like HTML templates, if AMD loader plugins are used,
then, depending on the loader plugin, they can inline their resources
as JS strings. Some loader plugins:
https://github.com/jrburke/requirejs/wiki/Plugins

Note the loader plugins have to take advantage of the loader plugin
build APIs that r.js supports to get the resource inlining:
http://requirejs.org/docs/plugins.html

James

On Sat, Jun 1, 2013 at 8:16 AM, Lyn Headley <lahe...@gmail.com> wrote:
> I'm aiming for an optimized experience in which a single html page contains
> all the javascript and css and markup needed for a single-page app. From
> what I can tell, this is not a standard practice in the requirejs community,
> which tends to take an approach where the html page is first loaded, and
> then one or more javascript and css files. Even in the optimized r.js case
> the standard practice seems to involve a minimum of three http requests for
> javascript. This is of course a vast improvement over an unoptimized build
> with dozens of amd modules, but I wonder how to push it further. Is this as
> simple as concatenating the require.js source and the result of an r.js run,
> and then inserting all this js code into a <script> tag in my html page?
>
> Is anybody doing this or thinking about it?
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "requirejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to requirejs+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>