https://github.com/psolbach/grip
:monkey_face: A lightweight include switch.
https://github.com/psolbach/grip
Last synced: about 1 month ago
JSON representation
:monkey_face: A lightweight include switch.
- Host: GitHub
- URL: https://github.com/psolbach/grip
- Owner: psolbach
- License: mit
- Created: 2014-05-26T12:41:35.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2014-06-05T14:08:09.000Z (about 12 years ago)
- Last Synced: 2025-02-21T19:25:23.353Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 301 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

grip.js
=======

Grip.js is a lightweight (1kb) insertion switch for Javascript files.
This can help replace Grunt or any other full-fledged build system in favor of a more minimal approach.
Borrowing from [require.js](https://github.com/jrburke/requirejs), a single script tag in your HTML will
1. Insert an array of unpacked Javascript modules for development.
2. Or a pretailored & minified production version of your JS.
### Performance
Your HTML remains untouched. Scripts are pulled in a dynamic fashion.
Field tests have proven that this can speed up perceived and actual load time -- so don't wander off just yet.
### Usage
Options live inside a `.js` which is referenced via data-attribute in the ``.
A sample embed would thusly look a whole lot like this:
<script charset="utf-8" data-options="modules.js" src="grip.min.js">
Your `modules.js` should resemble something like this:
'use strict';
window.opt = {
"debug": true,
"baseUrl": "optional/static/root",
"min": "/path/to/your.min.js",
"modules": [
"your",
"modules"
]
}
### Workflow with shell.js
Using a shell script in the flavor of [shelljs](https://github.com/arturadib/shelljs) one could go about and
fully integrate the generation of `modules.js` into the make/debug process.
Consider this snippet where d, b, p, m map to opt.debug, opt.baseUrl, opt.min, opt.modules.
function makeGrip(d,b,p,m) {
var o = { "debug": d, "baseUrl": b, "min": "/" + p,
"modules": d ? m : [] }, file = "'use strict'; window.opt = "
+ JSON.stringify(o)
file.to(conf.base + conf.modules);
}
### Questions?
Feel free to drop a line to p@psolbach.com or @___paul
### Acknowledgements
Aerosmith didn't sue. Yet.