Socket
Book a DemoInstallSign in
Socket

nomodule-browser-warning.js

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nomodule-browser-warning.js

Display a warning message for browser not supporting js modules

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

nomodule-browser-warning.js

NPM Downloads

How to use

Simple include the following script in your head. It will be ignored by browser supporting the module attribute.

Since js modules are supported by most browsers since 2018, showing this warning is a good way to run your javascript on modern browsers without having to rely on polyfills or transpiling.

The best thing in this is that it will have NO impact on performance on modern browsers that will simply ignore this line (and therefore keep your lighthouse results up ;-) ).

<head>
...
<script src="/js/nomodule-browser-warning.js" nomodule defer id="nomodule-browser-warning"></script>
</head>

How to configure

The script support the following data-attributes:

  • data-text: The text displayed in the notification
  • data-update-text: The label for the update button
  • data-ignore-text: The label for the ignore button
  • data-link: The link when you click on 'update' (https://browsehappy.com/ by default)
  • data-cookie: Shoud we store ignore in a cookie? (true, by default)

How does it look ?

screenshot

Keywords

DOM

FAQs

Package last updated on 21 Apr 2021

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