mon

monolith

Node.js module to aggregate CSS, JavaScript and images for inlining them into a single HTML document. Helpful for high-performance HTML apps.

Showing:

Popularity

Downloads/wk

2

GitHub Stars

3

Maintenance

Last Commit

10yrs ago

Contributors

0

Package

Dependencies

2

Size (min+gzip)

35.7KB

License

Type Definitions

Tree-Shakeable

No?

Categories

Readme

Monolith Build Status

Node.js module to aggregate CSS and JavaScript for inlining them into a single HTML document. Helpful for high-performance HTML5 apps.

Example

First, initialise the Monolith and add your CSS/JS files:

var monolith = require('monolith').init();

// Add our CSS.
monolith.addCSSFile(path.join("path", "to", "typography.css"));
monolith.addCSSFile(path.join("path", "to", "layout.css"));

// Add JavaScript.
monolith.addScriptFile(path.join("path", "to", "jquery-1.7.1.js"));
monolith.addScriptFile(require.resolve('underscore'));
monolith.addScriptFile(require.resolve('backbone'));

Then add them to your template rendering logic (the following will vary greatly depending on what sort of template rendering you use):

template.render({
  css: monolith.getCSS(),
  script: monolith.getScript()
};

Then, in the template, add the CSS and styles to the page (this examply uses Underscore templates, the syntax should be easy to figure out):

<head>
  <meta charset="utf-8">

  <title>Demo</title>

  <% _.each(css, function (code) { %>
  <style><%= code %></style>
  <% }); %>

  <% _.each(script, function (code) { %>
  <script><%= code %></script>
  <% }); %>
</head>

And you're done.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial