Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jokeyrhyme/noscript.js
stop other JavaScript (as best as can be done) and show `noscript` elements
https://github.com/jokeyrhyme/noscript.js
Last synced: 21 days ago
JSON representation
stop other JavaScript (as best as can be done) and show `noscript` elements
- Host: GitHub
- URL: https://github.com/jokeyrhyme/noscript.js
- Owner: jokeyrhyme
- License: bsd-2-clause
- Created: 2014-03-08T06:13:05.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-12-16T04:18:57.000Z (almost 8 years ago)
- Last Synced: 2024-10-14T21:23:38.702Z (25 days ago)
- Language: JavaScript
- Size: 23.4 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# noscript.js
stop other JavaScript (as best as can be done) and show `noscript` elements
Read more about it in my blog post: [All-Or-Nothing Enhancement](http://jokeyrhy.me/blog/2014/03/13/1/all-or-nothing-enhancement.html)
## Installation
You can just grab the `noscript.min.js` file from this repository, or you can
use Bower:- `bower install noscript`
## Usage
Include `noscript.js` on your web page. This installs a global `noscript`
object. You may want the poly-fills in the `lib` directory if you plan on using
this with older browsers.### noscript.show()
This will find all `noscript` elements on the page, and make their contents
visible, just as though the browser had JavaScript disabled.**Caution**: this will only work on elements that were on the page _before_
`noscript.show()` was called. That means that you'll likely want to do this
after all other HTML elements have been declared (e.g. at the bottom of the
`body` element.### noscript.lockdown()
There doesn't seem to be a way to disable JavaScript via JavaScript. So, this
method hunts down various APIs that govern side-effects (e.g. HTML DOM, AJAX,
etc) and tampers with them to the point where they hopefully become useless.**Caution**: you need to call this _after_ calling `noscript.show()`, because
that method will not work at all after `.lockdown()`. If you have no
`noscript` elements on the page, then feel free to call this as early as
possible. You'll want to call this _before_ any JavaScript to be blocked.## Example
```
...
Error: bad device or web browser
...
if (!window.JSON) {
noscript.show();
noscript.lockdown();
}
```