diff --git a/index.js b/index.js
index 3fa463b..41bdd2a 100644
--- a/index.js
+++ b/index.js
@@ -57,6 +57,19 @@ module.exports = function(html, styles, options) {
var noscript = $('');
var o = options || {};
+ if (_.isString(o.ignore)) {
+ o.ignore = [o.ignore];
+ }
+
+ if (o.ignore) {
+ links = links.filter(function() {
+ var href = $(this).attr('href');
+ return _.findIndex(o.ignore, function(arg) {
+ return _.isRegExp(arg) && arg.test(href) || arg === href;
+ }) === -1;
+ });
+ }
+
// minify if minify option is set
if (o.minify) {
styles = new CleanCSS().minify(styles).styles;
@@ -71,6 +84,8 @@ module.exports = function(html, styles, options) {
return $(this).attr('href');
}).toArray();
+
+
// extract styles from stylesheets if extract option is set
if (o.extract) {
if (!o.basePath) {
diff --git a/test/expected/external-ignore-expected.html b/test/expected/external-ignore-expected.html
new file mode 100644
index 0000000..c74dc62
--- /dev/null
+++ b/test/expected/external-ignore-expected.html
@@ -0,0 +1,407 @@
+
+
+
+
+ critical css test
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
'Allo, 'Allo!
+
+
Always a pleasure scaffolding your apps.
+
+
Splendid!
+
+
+
+
+
HTML5 Boilerplate
+
+
HTML5 Boilerplate is a professional front-end template for building fast, robust, and adaptable web apps or
+ sites.
+
+
Bootstrap
+
+
Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
+
+
+
+
+
+
+
diff --git a/test/index.js b/test/index.js
index b6a4113..f106679 100644
--- a/test/index.js
+++ b/test/index.js
@@ -103,4 +103,32 @@ describe('inline-critical', function() {
expect(strip(out.toString('utf-8'))).to.be.equal(strip(html));
done();
});
+
+ it('should respect ignore option with string', function(done) {
+ function strip2(string) {
+ return string.replace(/\s+/gm,'');
+ }
+
+ var html = read('test/fixtures/external.html');
+ var expected = read('test/expected/external-ignore-expected.html');
+ var css = read('test/fixtures/critical.css');
+ var out = inlineCritical(html, css, {ignore: ['bower_components/bootstrap/dist/css/bootstrap.css']});
+
+ expect(strip2(out.toString('utf-8'))).to.be.equal(strip2(expected));
+ done();
+ });
+ it('should respect ignore option with RegExp', function(done) {
+ function strip2(string) {
+ return string.replace(/\s+/gm,'');
+ }
+
+ var html = read('test/fixtures/external.html');
+ var expected = read('test/expected/external-ignore-expected.html');
+ var css = read('test/fixtures/critical.css');
+ var out = inlineCritical(html, css, {ignore: [/bootstrap/]});
+
+ expect(strip2(out.toString('utf-8'))).to.be.equal(strip2(expected));
+ done();
+ });
+
});