You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// foo.js & bar.js & thunkor.js & thunky.js is ready
102
+
}, function(depsNotFound) {
103
+
// foo.js & bar.js may have downloaded
104
+
// but ['thunk'] dependency was never found
105
+
// so lazy load it now
106
+
depsNotFound.forEach(function(dep) {
107
+
$script(dependencyList[dep], dep);
108
+
});
109
+
});
110
+
```
104
111
105
112
$script.path
106
113
------------
107
114
Optionally to make working with large projects easier, there is a path variable you can set to set as a base.
108
115
109
-
$script.path = '/js/modules/';
110
-
$script(['dom', 'event'], function () {
111
-
// use dom & event
112
-
});
116
+
```js
117
+
$script.path='/js/modules/';
118
+
$script(['dom', 'event'], function () {
119
+
// use dom & event
120
+
});
121
+
```
113
122
114
123
Note that this will include all scripts from here on out with the base path. If you wish to circumvent this for any single script, you can simply call <code>$script.get()</code>
115
124
116
-
$script.path = '/js/modules/';
117
-
$script(['dom', 'event'], function () {
118
-
// use dom & event
119
-
});
125
+
```js
126
+
$script.path='/js/modules/';
127
+
$script(['dom', 'event'], function () {
128
+
// use dom & event
129
+
});
120
130
121
-
$script.get('http://example.com/base.js', function () {
131
+
$script.get('http://example.com/base.js', function () {
122
132
123
-
});
133
+
});
134
+
```
124
135
125
136
Building $script.js
126
137
-------------------
127
-
Building $script.js requires NodeJS to be installed. To build, just run:
138
+
Building $script.js requires Node. To build, just run:
128
139
129
-
make
140
+
$ make
130
141
131
142
The copies of $script.js & $script.min.js that are in the dist folder will be overwritten with the newly built copies. The minified version of $script is compressed with [UglifyJS](https://github.com/mishoo/UglifyJS"UglifyJS").
132
143
133
144
*Note: you must init the UglifyJS submodule before running the makefile. To do this run:*
134
145
135
-
git submodule update --init
146
+
$ git submodule update --init
136
147
137
148
Common JS Support - added in v1.2
138
149
-----------------
139
150
140
151
Several folks have asked about [Common JS Module](http://commonjs.org) support. It's a bit unclear why this support is needed since $script itself can load files, and more than likely you're already loading your dependencies with something like [RequireJS](http://requirejs.org/). However it's also unknown what any given developer can be doing with $script, like for example injecting it into their existing headless unit testing framework -- therefore as of v1.2, $script will export itself as a module rather than exposing itself to the browser _window_ object.
0 commit comments