CSS Naked Day — Strip CSS


Don’t load CSS

With static site generators

This Pull Request explains how to use cronjobs and GitHub Workflows to remove styles from the build.

With PHP

<?php
  function isNakedDay() {
    $now = new \DateTime('now', new \DateTimeZone('UTC'));
    $start = new \DateTime('00:00, April 9', new \DateTimeZone('+14:00'));
    $end = new \DateTime('00:00, April 10', new \DateTimeZone('-12:00'));
    return $now >= $start && $now < $end;
  }
?>

Use it like this to disable stylesheets:

<head>
  …
  <?php if(!isNakedDay()) : ?>
    <link rel="stylesheet" href="styles.css" />
  <?php endif; ?>
  …
</head>

Revert CSS?!

This method is not the most performant one, but HTML elements will display as originally intended by the browser. It can be useful if you don’t manage the server yourself or if you want to keep the logic in your templates.

* { all: revert !important; } should reset all author styles to user or browser defined values.

In POSH, we can assign a cssnd class to <html> with JavaScript (or any other language of your choosing), then display a message at the top of the document:

  1. At the very top of the <head>, add the following:
    <style>
    	.cssnd * { all: revert !important; }
    </style>
    
    <script>
    	const today = new Date();
    	const isCSSND = today.getMonth() + 1 === 4 && today.getDate() === 9;
    	if (isCSSND) {
    		document.querySelector('html').classList.add('cssnd');
    	}
    </script>
  2. At the very end of the <body>:
    <template id="cssnd-callout">
    	My Site is celebrating <a href="https://css-naked-day.org/">CSS Naked Day</a>!
    </template>
    
    <script>
    	if (isCSSND) {
    		document.querySelector('body').prepend(document.querySelector('#cssnd-callout').content.cloneNode(true));
    	}
    </script>

If you need to keep some styling in your documents, you can use the following rule and add a no-cssnd class to any element. It will keep its styling, descendants included, until another cssnd is met:

@scope (.cssnd) to (.no-cssnd) {
	:scope, * {
		all: revert !important;
	}
}

Tools and plugins

Attention plugin developers! If you have a CSS Naked Day plugin for a popular CMS, or written in a programming language not listed here, feel free to open a pull request or drop us an email if you’re not familiar with Git.

Archives

This tools and plugins were developped and are not maintained anymore. Feel free to contact their author or implement your own: