Skip to content

Commit

Permalink
feat(helpers): add preconnect link
Browse files Browse the repository at this point in the history
increases lighthouse performances

closes #208
  • Loading branch information
MatteoGabriele committed Jan 8, 2020
1 parent f03818d commit 66e9ff4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/helpers.js
Expand Up @@ -10,11 +10,16 @@ export function loadScript (url) {
return new Promise((resolve, reject) => {
var head = document.head || document.getElementsByTagName('head')[0]
const script = document.createElement('script')
const link = document.createElement('link')

script.async = true
script.src = url
script.setAttribute('rel', 'preconnect')
script.charset = 'utf-8'

link.href = url

This comment has been minimized.

Copy link
@ricardogobbosouza

ricardogobbosouza Jan 8, 2020

@MatteoGabriele Wouldn't it be correct to use the domain instead of the script link?

This comment has been minimized.

Copy link
@MatteoGabriele

MatteoGabriele Jan 8, 2020

Author Owner

What do you mean by "script link"

link.rel = 'preconnect'

head.appendChild(link)
head.appendChild(script)

script.onload = resolve
Expand Down

0 comments on commit 66e9ff4

Please sign in to comment.