resource-hints.js 416 B

1234567891011121314151617181920212223
  1. 'use strict';
  2. const shouldAddResourceHints = options => {
  3. return !(options.prefetch.test.length === 0 &&
  4. options.preload.test.length === 0);
  5. };
  6. const createResourceHint = (rel, href) => {
  7. return {
  8. tagName: 'link',
  9. selfClosingTag: true,
  10. attributes: {
  11. rel: rel,
  12. href: href,
  13. as: 'script'
  14. }
  15. };
  16. };
  17. module.exports = {
  18. shouldAddResourceHints,
  19. createResourceHint
  20. };