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

              
                <div id="myLibrary"></div>

<script>
var instance = new myLib({
	selectorID: '#myLibrary',
	text: 'Hello Earth!',
	color: 'red'
});
</script>
              
            
!

CSS

              
                
              
            
!

JS

              
                (function(){

	// Merge options and initialize library
	const myLib = function(opts) {

		// Merge default options with user options
		this.options = Object.assign(myLib.defaults, opts);
		
		// Merge support for IE11
		/*function merge_options(defaults,user_options) {
			let new_options = {};
			let attrname;
			for (attrname in defaults) {
				new_options[attrname] = defaults[attrname];
			}
			for (attrname in user_options) {
				new_options[attrname] = user_options[attrname];
			}
			return new_options;
		}
		this.options = merge_options(myLib.defaults,opts);*/
		

		// Define merged options
		this.selector = document.querySelector(this.options.selector);
		this.text = this.options.text;
		this.color = this.options.color;


		// initialize library
		this.init();
	};


	// library logic
	myLib.prototype.init = function() {		
		this.selector.style.color = this.color;
		this.selector.innerHTML = this.text;
	};

	// Define default options
	myLib.defaults = {
		selector: '',
		text: 'Hello World!',
		color: 'black'
	};

	// Make accessible globally
	window.myLib = myLib;
})();



// THis normally goes in the HTML after including the library script. This is only here for demo porpuses
var instance = new myLib({
	selector: '#myLibrary',
	text: 'Hello Earth!',
	color: 'red'
});

              
            
!
999px

Console