• Stars
    star
    157
  • Rank 238,399 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 6 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A devtools extension for toggling CSS features allowing developers to see how pages/apps render in browsers that don't support modern CSS features

CSS Feature Toggle Extension

This devtools extension provides the ability to toggle-off CSS features, allowing developers to see how their pages and applications render and fallback in browsers that don't support modern CSS features.

Available for Chrome via the Chrome Web Store.

Screengrab of the CSS Feature Toggle extension

Supported browsers

This extension uses devtools API features that aren't supported in Firefox yet:

  • devtools.inspectedWindow.getResources()
  • devtools.inspectedWindow.onResourceAdded
  • resource.getContent()
  • resource.setContent()

Limitations

Toggling CSS features isn't supported everywhere yet so you should be aware of these caveats:

  • Inline styles (<div style="...">) will not be disabled.
  • Changes made to a stylesheet via the CSSOM will not be disabled.

Contributing

Installing for development

  1. Clone this repo.
  2. Start Chrome, open the Extensions manager and enable Developer Mode.
  3. Click Load unpacked extension and select the repo folder (the one containing manifest.json)
  4. Open devtools and click the CSS Features tab to use the extension.

Making code changes

  1. Update code
  2. Close/re-open devtools to see your changes

Testing

In the /tests/browser directory you'll find a test page which can be opened in a supported browser. The page contains one or more tests for each toggle. If you make changes and want to submit a pull request, please ensure the tests behave first. If you're adding a new toggle, please try to update the page with relevant tests or ask for assistance in your pull request.


How it works

The extension uses browser.devtools.inpectedWindow.getResources() to fetch the content of stylesheet and document resources loaded in the current window. For stylesheet resources, resource.getContent() is used to extract the style content. For document resources, a script is injected into the document which extracts the CSS content from <style> elements.

Extracted style content is passed through a series of regular expressions that rename the feature property/value/identifiers. The original content is then replaced with the modified CSS using either resource.setContent, for stylesheets or - for document styles - by injecteding a script to update the relevant <style> elements. For example:

  • display: flex becomes display: -disabled-flex
  • @supports (...) {} becomes @-disabled-supports (...) {}
  • transform: ... becomes @-disabled-transform: ... {}
  • width: calc(...) becomes width: -disabled-calc(...)

More Repositories

1

selectivizr

selectivizr is a JavaScript utility that emulates CSS3 pseudo-classes and attribute selectors in Internet Explorer 6-8.
JavaScript
1,715
star
2

ZzFXM

A super small music generator for use in size-limited JavaScript productions
JavaScript
382
star
3

gadebugger

A Chrome, Firefox & Opera devtools extension for debugging Google Analytics tracking code
JavaScript
238
star
4

3d-model-element

A custom element for rendering inline 3D models in a HTML document and allowing them to be transformed with CSS.
JavaScript
204
star
5

fuse-devtools

A boilerplate for creating a devtools extension for multiple browsers from a single code base.
JavaScript
134
star
6

JQuery-Extended-Selectors

Extends jQuery to add support for CSS3 xxx-of-type selectors
134
star
7

cssvr

CSSVR is an experiment that simulates browser support for creating VR experiences using media queries and CSS transforms.
JavaScript
82
star
8

ComputedStyleObserver

Prototype implementation of a `computedStyle` observer for DOM elements
JavaScript
19
star
9

surrogate

This is a tiny JavaScript library targeted at modern web browsers and designed to mimic the common parts of jQuery's funtions and syntax using modern ECMAScript and DOM implementations
JavaScript
4
star
10

imagedata

A collection of packages for working with images in JavaScript environments that don't implement the ImageData interface.
JavaScript
2
star
11

zzfxm-songs

A collection of songs for use with ZzFXM
2
star
12

sculpt

JavaScript
2
star
13

stylescribe

Stylescribe is a CSS documentation generator. It's goal is to produce a reference document that can be used to quickly build web pages without having to dive into the inner workings of a projects CSS.
JavaScript
2
star
14

atari-chunked-blits

Testing the feasibility of automatically breaking HOG blits into smaller chunks, allowing large objects to be drawn without interfering with interrupts
Assembly
2
star
15

selection-element

A web component for selecting HTML elements or other web components.
JavaScript
1
star