Adds the ability to differentially serve JavaScript on the basis of whether the current browser supports ES6 modules or not. This allows users to pay less of a penalty for when a site needs to support older browsers.
There is some extra wrangling to support edge cases where a browser may not respect the nomodule
attribute and would then potentially execute more scripts than desired.
Usage
In extension.libraries.yml
:
scripts:
js:
modern.js: { differential_serve: 'modern' } # ES6 only.
legacy.js: { differential_serve: 'legacy' } # ES5 only.
Gotcha: initial attached legacy scripts may not get their Drupal behavior attach()
methods called on the initial page load, due to the async nature of their loading.
Project information
- Minimally maintained
Maintainers monitor issues, but fast responses are not guaranteed. - Maintenance fixes only
Considered feature-complete by its maintainers. - Module categories: Developer Tools, Performance
- Created by Wongjn on , updated
- Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.
Releases
Adds support for Drupal 10
Development version: 8.x-1.x-dev updated 25 Sep 2022 at 10:10 UTC