123

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <!DOCTYPE HTML>
<html><head lang="en"><meta charset="utf-8" http-equiv="Content-Type" content="text/html; charset=UTF-8" /><meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0" />

<title>readystatus cursor script test -- RVKlein</title>

<style>
html.readystate--loading {cursor:wait;}
html.readystate--interactive {cursor:progress;}
html.readystate--complete {cursor:auto;}
</style>
<script>

(function()
{
var rootNode=(document.getElementsByTagName('*'))[0];
var $={DOM:{},has:{},origEventFn:{'onload':null,'onreadystatechange':null}};

$.has.documentReadyState=(
(	('undefined'!==typeof(document.onreadystatechange))
&&	('string'===typeof(document.readyState))
)?true:false);

$.has.DOM2Events=(
(	('function'===typeof(Event))
&&	('function'===typeof(EventListener))
&&	('function'===typeof(EventTarget))
&&	('function'===typeof(EventTarget.prototype.addEventListener))
&&	('function'===typeof(EventTarget.prototype.removeEventListener))
)?true:false);


/**/

$.DOM.classSet=function(el,cn)
{
	var attr='';
	if(el.hasAttribute('class'))
	{
		attr=((el.getAttribute('class')).split(' '));
		for(var i=0,j=attr.length;j>i;i++)
		{	if(attr[i]===cn)
			{	return(true);
		}	}
		attr=(attr.join(' ')+' ');
	}
	el.setAttribute('class',(attr+cn));
}

$.DOM.classRemove=function(el,cn)
{
	var out=[];
	if(el.hasAttribute('class'))
	{
		var attr=((el.getAttribute('class')).split(' '));
		for(var i=0,j=attr.length;j>i;i++)
		{	if(attr[i]!==cn)
			{	out[out.length]=attr[i];
		}	}
	}
	el.setAttribute('class',(out.join(' ')));
}

/**/

$.DOM.classSet(rootNode,'readystate--loading');
$.origEventFn.onload=window.onload;

$.whenDocumentReady=function()
{
	$.DOM.classRemove(rootNode,'readystate--loading');
	$.DOM.classSet(rootNode,'readystate--interactive');
};

if($.has.documentReadyState)
{
	$.origEventFn.onreadystatechange=document.onreadystatechange;

	document.onreadystatechange=function(evt)
	{
		if('complete'===document.readyState)
		{	$.whenDocumentReady();
		}
		if('function'===typeof($.origEventFn.onreadystatechange))
		{	($.origEventFn.onreadystatechange)(evt);
		}
	};
}

if($.has.DOM2Events)
{
	document.addEventListener('DOMContentLoaded',$.whenDocumentReady);
}

window.onload=function(evt)
{
	$.DOM.classRemove(rootNode,'readystate--loading');
	$.DOM.classRemove(rootNode,'readystate--interactive');
	$.DOM.classSet(rootNode,'readystate--complete');
	if('function'===typeof($.origEventFn.onload))
	{	($.origEventFn.onload)(evt);
	}
};

})();
</script>

</head><body>

<main>
<blockquote>
	<p>Ideally, this should work and gracefully degrade in older browsers. How much older? I don't know.</p>
	<p>This does a simple thing: it changes the mouse cursor to a load spinner type while hovering the document if it is still loading. It does this by switching between CSS classes applied to the root element as the load state progresses.</p>
	<p>To get a better idea of how this is useful, try putting a whole bunch of markup and maybe some big images into the document, then use the network tools in your inspector panel to ensure your load is at 2G/3G mobile speed.</p>
</blockquote>
<p>[ Made with love from <a href="https://rvklein.neocities.org/">R.V.Klein</a>. ]</p>
</main>

</body></html>

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console