Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Disable All CSS on a Page with JavaScript

Let’s say you want to verify the order in which the content is displayed, or you want to test the accessibility of a page when styles are disabled.

We can do that by running a single line of Javascript.

Let’s get started!

Remove CSS on a Page

Go to a page for which you want to disable the styles and open the browser console (F12).

Before running the Code I just want to let you know that pasting JavaScript code into the browser console can pose security risks.

The code could steal sensitive information and exploit vulnerabilities. Do not paste JavaScript code from untrusted sources.

Now that I’ve made that clear, you can run the following code:

e.remove());" style="color:#d8dee9ff;display:none" aria-label="Copy" class="code-block-pro-copy-button">
document.querySelectorAll('style, link[rel="stylesheet"]').forEach(e => e.remove());

The code finds all the and elements on the page and removes them.

This is what the Neutron Dev YouTube page looks like without CSS:

Full video walkthrough:



This post first appeared on Neutron Dev, please read the originial post: here

Share the post

Disable All CSS on a Page with JavaScript

×

Subscribe to Neutron Dev

Get updates delivered right to your inbox!

Thank you for your subscription

×