fix(snippet): Allow async attribute to be removed from snippet with s… · BrowserSync/browser-sync@c32bec6 · GitHub
Skip to content

Commit c32bec6

Browse files
author
Shane Osbourne
committed
fix(snippet): Allow async attribute to be removed from snippet with snippetOptions.async = false - fixes #670
1 parent 3503a54 commit c32bec6

4 files changed

Lines changed: 40 additions & 5 deletions

File tree

lib/connect-utils.js

Lines changed: 3 additions & 2 deletions

lib/default-config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,19 +158,21 @@ module.exports = {
158158
logSnippet: true,
159159

160160
/**
161-
* SINCE 1.7.0! You can control how the snippet is injected
161+
* You can control how the snippet is injected
162162
* onto each page via a custom regex + function.
163163
* You can also provide patterns for certain urls
164164
* that should be ignored from the snippet injection.
165165
* @property snippetOptions
166166
* @since 2.0.0
167+
* @param {Boolean} [async] - should the script tags have the async attribute?
167168
* @param {Array} [blacklist]
168169
* @param {Array} [whitelist]
169170
* @param {RegExp} [rule.match=/<body[^>]*>/i]
170171
* @param {Function} [rule.fn=Function]
171172
* @type Object
172173
*/
173174
snippetOptions: {
175+
async: true,
174176
whitelist: [],
175177
blacklist: [],
176178
rule: {

lib/templates/script-tags.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<script type='text/javascript' id="__bs_script__">//<![CDATA[
2-
document.write("<script async src='%script%'><\/script>".replace("HOST", location.hostname));
3-
//]]></script>
2+
document.write("<script %async%src='%script%'><\/script>".replace("HOST", location.hostname));
3+
//]]></script>
Lines changed: 32 additions & 0 deletions

0 commit comments

Comments
 (0)