JavaScript - Enabling JavaScript
Overview
Estimated time: 10–15 minutes
Most browsers have JavaScript enabled by default. If scripts don't run, use the quick test below and check settings.
Learning Objectives
- Verify whether JavaScript is enabled in your browser.
- Know where to turn it on in popular browsers.
- Troubleshoot common issues (CSP, extensions, 404s).
Prerequisites
Quick Test
<!DOCTYPE html>
<html>
<body>
<h1>JS Check</h1>
<script>document.body.insertAdjacentHTML('beforeend', '<p>JavaScript is enabled</p>');</script>
<noscript><p style="color:red">JavaScript appears to be disabled.</p></noscript>
</body>
</html>
Enable in Popular Browsers
- Chrome: Settings → Privacy and security → Site settings → JavaScript → Sites can use JavaScript.
- Safari (macOS): Safari → Settings → Security → Enable JavaScript.
- Firefox: JS is enabled by default. If toggled, set
javascript.enabled
totrue
inabout:config
. - Edge: Settings → Cookies and site permissions → JavaScript → Allowed.
Troubleshooting
- Check the DevTools Console for errors (404 on script file, syntax errors).
- Ensure your
<script src>
path and filename are correct. - Extensions (ad blockers) may block scripts — try a private window with extensions disabled.
- Hosted pages may use CSP that blocks inline scripts. Prefer external files or add required nonce/hash.
Checks for Understanding
- How can you quickly confirm that JavaScript is enabled on a page?
- Where do you enable JavaScript in Chrome or Safari?
Show answers
- Add a small inline script that writes to the DOM (or check for a message in the Console); use
for fallback.
- Chrome: Settings → Privacy and security → Site settings → JavaScript → Sites can use JavaScript. Safari: Settings → Security → Enable JavaScript.
Exercises
- Create a test page that inserts a "JS enabled" message via
document.body.insertAdjacentHTML
and shows awarning.
- Open DevTools Console and verify no errors when your script runs. If there are errors, fix the path or syntax.