In-lining / including CSS and JavaScript files #438

barberboy opened this Issue Dec 14, 2011 · 7 comments

7 participants


I have a small, one-page web application and I'd like to include all the CSS and JavaScript in-line in style and script tags, rather than linking to external files. However, I'd like to manage them as separate files in my source.

Is there a way to (conceptually) do:

  include ../scripts/app.js

Obviously, Jade parses the "include..." as text content for the script tag and doesn't interpret it as template code, so the above snippet does not work. I'm just wondering if there is a simple workaround that I'm missing that would accomplish the same thing.


I'm using this workaround now and it's working fine:

| <style type="text/css">
include ../styles/style.min.css
| </style>

| <script>
include ../scripts/app.min.js
| </script>
@barberboy barberboy closed this Dec 15, 2011

I hit this issue as well. It would be nice to have a documented best practice for this case...


Yes, it seems that some way of 'inverting' style and script behavior is needed


Just hit this as well. Agree.

@tj tj added a commit that referenced this issue Jan 9, 2013
@tj tj add .css and .js "filters". re #438
include some.js
include some.css
tj commented Jan 9, 2013

you can now do:

include some.js
include some.css

and it'll add the tags


Interesting. I actually want to include a .coffee and .js file in pre tags for display... It works great w/ a ,json file, but I also want to include the CoffeeScript (and compiled JavaScript) into my docs....

Any options for me here?

Pug member

See #1255 this feature is changing, so you will be able to do this in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment