Should JamJS load CSS?

193 views
Skip to first unread message

Rob Loach

unread,
Sep 26, 2012, 10:32:04 AM9/26/12
to ja...@googlegroups.com
JamJS and RequireJS are fantastic as script loaders to handle JavaScript. It might be nice if JamJS also told RequireJS to load the library's associated CSS files?
http://requirejs.org/docs/faq-advanced.html#css

{
  "name": "myproject",
  "version": "0.0.1",
  "description": "An example Node.js project",
  "dependencies": {
    // NPM dependencies go here...
    "async": "0.1.22"
  },
  "jam": {
    "dependencies": {
      // Jam dependencies go here...
      "jquery": "1.7.1",
      "underscore": null
    },
"css": [
"example.css",
"myothercssfile.css"
],
"main": "example.js"
  } }

Caolan McMahon

unread,
Sep 26, 2012, 12:29:03 PM9/26/12
to ja...@googlegroups.com
That would be useful in some circumstances, but often the order of
included CSS files matters. Developers should be able to override and
order CSS files easily, without the package including them
automatically.

I'd be interested in hearing other peoples thoughts on this though,
because I can see some circumstances where it could make sense to
include the CSS (date select widget perhaps?).

Caolan
> --
> You received this message because you are subscribed to the Google Groups "jamjs" group.
> To post to this group, send an email to ja...@googlegroups.com.
> To unsubscribe from this group, send email to jamjs+un...@googlegroups.com.
> To view this discussion on the web, visit https://groups.google.com/d/msg/jamjs/-/v_kax79KQzIJ.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Rob Loach

unread,
Oct 10, 2012, 12:39:01 PM10/10/12
to ja...@googlegroups.com

Nebojsa Sabovic

unread,
Oct 18, 2012, 4:29:27 PM10/18/12
to ja...@googlegroups.com
I've been using requirecss with Jam and it works great for injecting css.

Guillaume Lambert

unread,
Oct 29, 2012, 2:57:15 PM10/29/12
to ja...@googlegroups.com
So you add it manually to your project alongside Jam? Or you found a way to add it to the jam dependencies?

Tim Caswell

unread,
Oct 29, 2012, 3:14:10 PM10/29/12
to ja...@googlegroups.com
I've been playing with TJ's component system. <https://github.com/component>.  It bundles both css and javascript in it's modules.

One issue I recently found while bundling font-awesome for it was that when it concats all the dependent css files together, their relative links break.  Joining CSS is not an easy problem.  My solution was to rewrite the urls in the css on the fly (when building) to point to the data folders.

In Jam, I just included the css files manually using link tags, if you're dynamically loading in css using javascript just make sure to rewrite relative urls when moving css files around.  Unlike javascript files, the css source does care what it's relative to.

Guillaume Lambert

unread,
Oct 29, 2012, 3:17:53 PM10/29/12
to ja...@googlegroups.com
Indeed you are right.

I'm currently using StealJS and this is taken of when building the production files.


I might stick with Steal for now, even tho its not as clean as Jam or Volo and not AMD (for now), but it works well other than that !
Reply all
Reply to author
Forward
0 new messages