Hexo: JS Helper should have the ability to add async/defer/integrity attributes

Created on 24 Aug 2019  路  4Comments  路  Source: hexojs/hexo

Check List

Please check followings before submitting a new feature request.

  • [x] I have already read Docs page
  • [x] I have already searched existing issues

Feature Request

The default js() helper should ideally have the ability to add attributes like async and defer, which can help significantly with time-to-first-paint. Perhaps to maintain backwards compatibility, take in either a string which maintains current behavior, or an object which could have the attributes as keys.

feature-request

All 4 comments

Thanks! I checked issues, but I didn't think to check PRs. Looking forward to that landing!

As not to disappoint you, since this feature is not high priority (can always use <script>), most probably it won't be part of v4 release. But I'll try my best to land this in v4.1.

Btw, in the meantime, you could also consider a custom JS helper with this ability.
Simply add this file into the scripts/ folder, and use <%- addJs({src: '', integrity: ''}) %> (function name is customizable). The only difference is that path name must ends with .js.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wych42 picture wych42  路  23Comments

icepy picture icepy  路  34Comments

tomap picture tomap  路  21Comments

fishercoder1534 picture fishercoder1534  路  26Comments

fabien-h picture fabien-h  路  22Comments