Use Notyf globally via `<script>` tags
masterTo use Notyf without a module bundler, you can include the minified JavaScript and CSS files directly in your HTML.
- Install Notyf via npm:
npm i notyf. - Copy
node_modules/notyf/notyf.min.jsandnode_modules/notyf/notyf.min.cssto your project's public assets folder. - Include the CSS in the
<head>of your document. - Include the JS script before the closing
</body>tag.
Important: Ensure you initialize Notyf and any custom scripts after the Notyf script tag is loaded.
<!DOCTYPE html>
<html lang="en">
<head>
...
<link href="path/to/notyf.min.css" rel="stylesheet">
</head>
<body>
<button id="send-button">Send</button>
...
<script src="path/to/notyf.min.js" type="application/javascript"></script>
<script type="application/javascript">
var notyf = new Notyf({
duration: 5000 // Set your global Notyf configuration here
});
</script>
<script src="scripts/your-custom-script.js" type="application/javascript"></script>
</body>
</html>