Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async attribute #52

Closed
limonte opened this issue Jul 21, 2014 · 7 comments
Closed

Async attribute #52

limonte opened this issue Jul 21, 2014 · 7 comments

Comments

@limonte
Copy link

limonte commented Jul 21, 2014

It would be great to have ability to add async attribute to script tag generated by gulp-usemin.

It's often very useful: https://developers.google.com/web/fundamentals/performance/critical-rendering-path/adding-interactivity-with-javascript#parser-blocking-vs-asynchronous-javascript

@woutrbe
Copy link

woutrbe commented Jul 30, 2014

I feel there should be an options to overwrite the script tags generate by gulp-usemin, I currently have a case where I have to add a class to my script tag.

@klwemu
Copy link

klwemu commented Nov 22, 2014

We need async too. Vote for this feature!

@futurechan
Copy link

@craigmdennis
Copy link

+1

2 similar comments
@Snugug
Copy link

Snugug commented Jul 1, 2015

👍

@sbley
Copy link

sbley commented Oct 26, 2015

+1

@sohamkamani
Copy link
Contributor

Just a suggestion - we could have these attributes as an object passed inside the build task,

for example :

var jsAttributes = {
  async : true,
  'some-other-attribute' : 'some-value'
  };
gulp.task('usemin', function() {
  return gulp.src('./*.html')
    .pipe(usemin({
      css: [ rev() ],
      html: [ minifyHtml({ empty: true }) ],
      js: [ uglify(), rev() ],
      jsAttributes: jsAttributes,
      inlinejs: [ uglify() ],
      inlinecss: [ minifyCss(), 'concat' ]
    }))
    .pipe(gulp.dest('build/'));
});

would give you

<script src="build.js" async some-other-attribute="some-value"></script>

I guess this would solve #75 and #77 as well.

Thoughts?

zont added a commit that referenced this issue Nov 25, 2015
Added feature to assign attributes to js script tags (Solves #52, #75, #77 )
@limonte limonte closed this as completed Apr 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants