Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Simple Feature Policy Reporting</title>
</head>
<body>
  <h1>Feature Policy Reporting Demo</h1>
  <p>A quick and dirty example of how you could watch for Feature Policy violations using a ReportingObserver, and then display them prominently on the page to make them visible.</p>
  <p>To see the Feature Policies in action, you'll need to:</p>
  <ol>
    <li>Be using a Blink-based browser</li>
    <li>Have Experimental Web Platform Features enabled (about:flags)</li>
    <li>Enable a Feature-Policy header (<code>unsized-media</code> and <code>oversized-images</code> should do the trick) somehow (I like <a href="https://chrome.google.com/webstore/detail/modheader/idgpnmonknjnojddfkpgkljpfnnfcklj?hl=en">ModHeader</a>)</li>
  </ol>
  <img src="https://via.placeholder.com/300" alt="">
  <img src="https://via.placeholder.com/600" width="100" alt="">

</body>
</html>
              
            
!

CSS

              
                body {
  padding-bottom: 0;
  font: 100%/1.4em Helvetica, Arial, sans-serif;
}
#reportingAlerts{
  background: #282828;
  color: #fff;
  padding: 1em;
  border-top: 5px solid #da1e28;
  position: fixed;
  top: 1em;
  right: 1em;
  padding: 1em;
  list-style: none;
}
#reportingAlerts li+li{
  margin-top: 1em;
}
#reportingAlerts li:before{
  content: 'x';
  color: #fff;
  background: #da1e28;
  border-radius: 50%;
  padding: .3em .6em;
  line-height: 1em;
  margin-right: .5em;
}
              
            
!

JS

              
                let reportingAlerts = document.createElement('ul');
  reportingAlerts.setAttribute('id','reportingAlerts');
  document.body.appendChild(reportingAlerts);

const alertBox = document.getElementById('reportingAlerts');

new ReportingObserver((reports, observer) => {
  let fragment = document.createDocumentFragment();
  
  Object.keys(reports).forEach(function(item) {
    let li = document.createElement('li');
    li.textContent = reports[item].body.message + ': ' + reports[item].body.featureId;
    fragment.appendChild(li);
  });
  
  alertBox.appendChild(fragment)
}, {types: ['feature-policy-violation'], buffered: true}).observe();
              
            
!
999px

Console