What is a script blocker and what does it do?

689 views

Also, how does it work and what are some examples of it?

In: Technology

4 Answers

Anonymous 0 Comments

It helps to understand how pages are loaded in a browser.

First: the “page” is just a big mess of text when the browser first gets it. That text uses special rules to form a “markup language” named HTML. (A “markup language” is a fancy term for a way to write text that makes text look fancier when a program processes it. You know how you can make text bold with * asterisks on Reddit? That’s a simple markup language!)

Once the browser gets the text, it starts “parsing” it. That’s the fancy word for reading the text and deciding what it means. Some parts of the HTML language tell the browser either there is a “script” file that should be downloaded *or* some part of the text is in fact not HTML, but a script.

A “script” is some more text, but this time instead of a markup language, it’s a programming language. These days it’s usually JavaScript, but technically it can be any language the browser supports. Scripts exist to do things. They contain small programs that might change the HTML after the browser is done with it. See, HTML isn’t what we call “dynamic”. That means without scripts, an HTML file looks one way and can’t change. You know how sometimes stuff on a page gets bigger when your mouse is over it? That’s *impossible* with just HTML. Scripts are one way to be able to make that happen.

(Some programmers get really upset if HTML is or isn’t called a “programming language”. They worry if it’s called a “markup language” then people think it’s easier. HTML is a simple language to describe and a hard language to understand fully once scripts and something else called “style sheets” get involved, and people who say otherwise probably haven’t ever really had to use them.)

Anyway, once the browser sees there’s a script to download, it downloads it. Other parts of the HTML might tell the browser to run some or all of the program code in the script.

A lot of times scripts are used for things you might not like. It’s extremely common for scripts to try to glean information about you from your browser, then load ads. Sometimes they’re innocent and only for some fancy effects, but scripts can take time to run and also make your CPU work harder. Sometimes they do even more malicious things, like try to steal data from you.

So browsers support “extensions”. These are programs that run inside of the browser and are able to do things to web pages. A “script blocker” tells the browser it wants to be part of loading pages. So when the browser starts parsing the HTML, it tells the script blocker what it’s parsing. When the script blocker sees a script is about to be loaded, it decides if it thinks that script is good or bad. If it thinks that script is bad, it tells the browser to not bother loading it at all. If the script doesn’t load, it doesn’t run.

You are viewing 1 out of 4 answers, click here to view all answers.