Tag: Listen

Listen to your web pages

A clever idea from Tom Hicks combining MutationObserver (which can “observe” changes to elements like when their attributes, text, or children change) and the Web Audio API for creating sounds. Plop this code into the console on a page where you’d like to listen to essentially any DOM change to hear it doing stuff.

I played with it on my serverless site because it’s an SPA so there is plenty of DOM activity as you navigate around.

const audioCtx = new (window.AudioContext || window.webkitAudioContext)() const observer = new MutationObserver(function(mutationsList) {   const oscillator = audioCtx.createOscillator()    oscillator.connect(audioCtx.destination)   oscillator.type = "sine"   oscillator.frequency.setValueAtTime(     Math.log(mutationsList.length + 5) * 880,     audioCtx.currentTime,   )    oscillator.start()   oscillator.stop(audioCtx.currentTime + 0.01) })  observer.observe(document, {   attributes: true,   childList: true,   subtree: true,   characterData: true, })  

Looks like Tom is experimenting with other audio… what should we call them? Auralizations? Like this sweep-swoop one. There is already a browser extension for it, which includes sounds for network activity happening.

Direct Link to ArticlePermalink

The post Listen to your web pages appeared first on CSS-Tricks.

CSS-Tricks

,