Add preconnect to speed up loading resources

Created on 18 August 2023, over 1 year ago

Problem/Motivation

Currently the module does not provide a preconnect link.

Proposed resolution

Implement a preconnect.

Feature request
Status

Active

Version

2.1

Component

Code

Created by

🇧🇪Belgium yoerioptr

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @yoerioptr
  • Status changed to Needs work over 1 year ago
  • 🇧🇪Belgium dieterholvoet Brussels

    Thanks for the patch! Since it's possible to choose your own script source, you should also

    • make href dynamic, take the scheme + host of the script instead of hardcoding to plausible.io
    • only add this if the host is different from the current domain (taken from \Drupal::request())
  • Status changed to Closed: won't fix about 1 month ago
  • 🇧🇪Belgium dieterholvoet Brussels

    I had a better look at the documentation and I don't believe that a preconnect link is very useful here.

    These two resource hints are helpful for improving page speed when you know you'll download something from a third-party domain soon, but you don't know the exact URL for the resource. Examples include CDNs that distribute JavaScript libraries, images or fonts. Be mindful of constraints, use preconnect only for the most important resources, rely on dns-prefetch for the rest, and always measure the impact in the real-world.

    Since the Plausible script is a static file on a static path, we do know the exact URL, and we know it'll be cached by the browser which makes a preconnect not necessary. The preconnect could be useful for the AJAX call the script is making to track the event, but that tracking call really shouldn't be considered a priority.

    Sources:

Production build 0.71.5 2024