@wprimadi/lockdown
v1.0.0
Published
LOCKDOWN (Log Obfuscation & Console Kill-switch with Devtools Override Warning Network) - Lightweight JavaScript library to secure your website by blocking DevTools access, disabling context menu, shortcuts, text copy/cut/select, and more. Built for front
Maintainers
Readme
LOCKDOWN 🛡️
Log Obfuscation & Console Kill-switch with Devtools Override Warning Network
LOCKDOWN is a lightweight JavaScript library designed to protect your website from unwanted user interactions such as opening DevTools, copying text, right-clicking, and more. This library helps you add an extra layer of front-end security in just a few lines of code.
✨ Features
- 🔒 Detect and block browser DevTools
- 🖱️ Disable right-click (context menu)
- 🧠 Block keyboard shortcuts like F12, Ctrl+Shift+I, Ctrl+U, etc.
- 📋 Prevent text copy and cut
- ❌ Disable text selection
- 🚫 Block mouse down actions
- 🔄 Optional redirect when DevTools is detected
🚀 Getting Started
1. Install
You can include it directly in your HTML file:
<script src="lockdown.js"></script>Or serve it via NPM/CDN:
CDN
You can include B.A.R.R.I.C.A.D.E from a CDN:
<script src="https://cdn.jsdelivr.net/gh/wprimadi/[email protected]/lockdown.min.js"></script>Or the latest version:
<script src="https://cdn.jsdelivr.net/gh/wprimadi/lockdown/lockdown.min.js"></script>NPM
Install via NPM:
npm install @wprimadi/lockdownOr use it from the CDN NPM package:
<script src="https://cdn.jsdelivr.net/npm/@wprimadi/lockdown/lockdown.min.js"></script>For more details, visit the NPM page.
2. Initialize
window.addEventListener('DOMContentLoaded', () => {
lockdown.init({
redirectUrl: '/access_denied', // URL to redirect when DevTools is opened
disableContextMenu: true, // Default: true
disableShorcuts: true, // Default: true
disableTextCopy: true, // Default: true
disableTextCut: true, // Default: true
disableTextSelection: true, // Default: true
disableMouseDown: true, // Default: true
disableDevTools: true // Default: true
});
});All options are optional. If omitted, they will use the default values.
⚙️ Configuration Options
| Option | Type | Default | Description |
|------------------------|----------|---------------|--------------------------------------------------------------------------|
| redirectUrl | string | empty string | URL to redirect when DevTools is detected. Leave empty to skip redirect. |
| disableContextMenu | bool | true | Disable right-click menu. |
| disableShorcuts | bool | true | Block developer tool-related keyboard shortcuts. |
| disableTextCopy | bool | true | Prevent users from copying text. |
| disableTextCut | bool | true | Prevent users from cutting text. |
| disableTextSelection | bool | true | Disable text selection on the page. |
| disableMouseDown | bool | true | Disable mouse down interaction. |
| disableDevTools | bool | true | Enable/disable DevTools detection mechanism. |
🔐 Use Case
LOCKDOWN is perfect for:
- Web-based quizzes or assessments
- SaaS dashboards with sensitive UI elements
- Public landing pages where copying or debugging is discouraged
- Frontend-only applications requiring extra client-side security
🌐 Compatibility
LOCKDOWN has been tested and verified on the following browsers:
⚠️ Disclaimer
This library only provides basic obfuscation and deterrence. It is not a foolproof security solution and should be used alongside proper backend validation and security best practices.
📄 License
MIT License © 2025 Wahyu Primadi
