Skip to content


Work around missed srcipts #8

merged 1 commit into from

2 participants


This should fix missed scrips in previous pull request.

It preserves any script attributes so defer in not important in my opinion.

@mklabs mklabs merged commit f592435 into mklabs:dev

That's great. Thanks!


You're totaly true on the defer attribute, that should be left to the user responsability to know whether they want the script defer attribute or not.

To let you know, I'm working on a jsdom implementation and I aim at integrate the work that have been done here:

It's still al little bit clumpsy but this is a nice alternative to all these fancy regexp, not sure yet how the whole will be packaged and what the overall api might look like.


I will look at this :)
What concerns me is scripts like:

How can jsdom handle it?


It'll be "regular" jQuery code (with some node fs api here and there... that's what is fun!) so I guess this will be addressed with something like

<script data-build-to="something" data-build-fallback="true">window.jQuery || document.write('<script src="js/libs/jquery-1.6.2.min.js"><\/script>')</script>

The whole idea is to use data-* attributes to drives the output of the build script, or inline html comments to reduce down the configuration. Ideally, this should be something that you run on a bunch of html files (or other extension) and the script should guess what to do from the html markup.

See #1 or h5bp/html5-boilerplate#831 for the original idea / discussion.


I must think about it :)

I am watching backbone-boilerplate and they just use require.js for all of this ;-)
But without usemin.

In those repo I dont like:

  • not reving
  • not usemin (this disables in my opinion using cache)
  • concatenation of almost all scripts (if only one use "strict mode" app will crash)

In proposal I like:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 29, 2012
  1. @krzychukula
Showing with 7 additions and 5 deletions.
  1. +7 −5 tasks/usemin.js
12 tasks/usemin.js
@@ -30,20 +30,22 @@ task.registerBasicTask('usemin', 'Replaces references to non-minified scripts /
log.writeln('switch from a regular jquery to minified');
log.writeln('Update the HTML to reference our concat/min/revved script files');
- content = content.replace(/<script.+src=['"](.+)\/([^\/"']+)["'][\/>]?><\/script>/gm, function(match, prefix, src) {
+ content = content.replace(/<script.+src=['"](.+)["'][\/>]?><[\\]?\/script>/gm, function(match, src) {
//do not touch external files
- if(prefix.match(/\/\//)) return match;
+ if(src.match(/\/\//)) return match;
+ var basename = path.basename(src);
+ var dirname = path.dirname(src);
- var filename = path.basename((file.expand(path.join(config('output'), '**/*') + src)[0] || ''));
+ var filename = path.basename((file.expand(path.join(config('output'), '**/*') + basename)[0] || ''));
// replace the output dir prefix
filename = filename.replace(config('output'), '');
// handle the relative prefix (with always unix like path even on win32)
- filename = [prefix, filename].join('/');
+ filename = [dirname, filename].join('/');
// if file not exists probaly was concatenated into another file so skip it
- return filename ? '<script defer src=":file"></script>'.replace(':file', filename) : '';
+ return filename ? match.replace(src, filename) : '';
log.writeln('Update the HTML with the new css filename');
Something went wrong with that request. Please try again.