Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gatsby-plugin-preconnect

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gatsby-plugin-preconnect

Gatsby plugin to add the crossorigin attribute to every <link rel="preload"> tag

  • 1.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

gatsby-plugin-preconnect

Quickly add a <link rel="preconnect" crossorigin> tag for every specified domain.

Build Status Build Status Renovate enabled Commitizen friendly semantic-release Open Source
Love npm

Install

npm install --save gatsby-plugin-preconnect

What this plugin does

It simply adds a <link rel="preconnect" href="https://example.com" crossorigin> to the page (see the Resource Prioritization - Preconnect guide).

How to use

// In your gatsby-config.js
plugins: [
  {
    resolve: 'gatsby-plugin-preconnect',
    options: {
      domains: ['https://foo.com', 'https://bar.com'],
    },
  },
]

crossOrigin is set to true by default but it can be customized, below all the available options

plugins: [
  {
    resolve: 'gatsby-plugin-preconnect',
    options: {
      domains: [
        'https://foo.com',
        'https://bar.com',
        { domain: 'https://enablecors.com', crossOrigin: true },
        { domain: 'https://disablecors.com', crossOrigin: false },
        { domain: 'https://corswithanonymous.com', crossOrigin: 'anonymous' },
        { domain: 'https://corswithcreds.com', crossOrigin: 'use-credentials' },
      ],
    },
  },
]

All the available values for crossOrigin are listed below, every other value makes the plugin throw an error

ValueEquivalent value
undefined"anonymous"
true"anonymous"
"anonymous""anonymous"
"use-credentials""use-credentials"
false(attribute not added)

Contributing

PR or issues are welcome 👋

Notes
  • if you want to work on the plugin sources, remember that you need to npm run build on the root then, in every test project, you need to run npm run plugin:link to locally use it

Contributors

Thanks goes to these wonderful people (emoji key):


Stefano Magni

💻 📖

Dugagjin Lashi

💻 👀

Sean King

🤔

Andrew Schneider

💻 📖 ⚠️

Andreas Donig

🤔

This project follows the all-contributors specification. Contributions of any kind welcome!

Keywords

FAQs

Package last updated on 02 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc