# iframer

> IFRAMEr makes your web components portable and your life easier

Latest version **1.0.0** (published 2015-08-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install iframer
pnpm add iframer
yarn add iframer
bun add iframer
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2015-08-03 |
| First published | 2015-08-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11 |
| Author | Vlad Mysla |
| Maintainers | vmysla |
| Keywords | iframe, widget, frontend, portable, wrapper, cross-platform |

## Links

- npm: https://www.npmjs.com/package/iframer
- Repository: https://github.com/vmysla/IFRAMEr
- Homepage: https://github.com/vmysla/IFRAMEr#readme
- Issues: https://github.com/vmysla/IFRAMEr/issues
- npm.io page: https://npm.io/package/iframer

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2015-08-03

## README

IFRAMEr makes your components portable and your life easier.

If you look for a simple approach which helps creating reusable web components - IFRAMEr might be exactly what you need. This is a small JavaScript function that wraps your `html` markup with all `styles` and `scripts` you need for its work - into dynamically created `iframe` element, so page can't suddenly break the original design of your component.

## Overview 

Enjoy with the demo on JsFiddle first: https://jsfiddle.net/vmysla/7rhgoeuq/3/embedded/result/

![IFRAMEr solved my problem](http://content.screencast.com/users/vmysla/folders/Default/media/f71f289a-fce4-444b-856a-86b8f3c7cce4/iframer.png)

Demo: https://jsfiddle.net/vmysla/7rhgoeuq/3/embedded/result/

IFRAMEr has no dependencies. 
Total size for minified version of the script is 495 bytes gzipped (798 bytes uncompressed). 
You can extend and customize it by adding own tasks. 

Feel free to fork: `git clone https://github.com/vmysla/IFRAMEr`

## Get started

Widget is any web component which is wrapped into IFRAME for its wide distribution in the web. 
You can create widgets from any frontend element you have on the page:

``` html
    ...
	<h1>This is a page</h1>
	...
	<!-- Let's say, this is the part of your page which you want to reuse on different sites: --> 
	<style> 
		b { color : red; } 
	</style>
	<div>
    	Hi! <br/> I'm simple <b id="term">html element</b>!
    </div>
    <script type="widget/javascript">
	    document.getElementById('term').innerHTML = 'web component';
	</script>
	...
```
It has own HTML markup, CSS styles and JavaScript code as well.
To make a widget - you have to put all those things into script tags with special type attributes: 

####1. Wrap your `HTML` code with the `script[type=widget/html]` tag
``` html
	<script type="widget/html">
		<style> 
			b { color : red; } 
		</style>
		<div>
	    	Hi! <br/> I'm simple <b id="term">web component</b>!
	    </div>
	</script>
```
####2. Put your `JavaScript` code for widget into `script[widget/javascript]`, right after 1.
``` html
	<script type="widget/javascript">
	    document.getElementById('term').innerHTML = 'iframe widget';
	</script>
```
####3. Add `IFRAMEr` script just before closing `body` tag
``` html
     ...
     <script src="//rawgit.com/vmysla/IFRAMEr/master/dist/iframer.min.js"></script>
  </body>
```

Because all your markup and code are placed into own script tags - browser wouldn't render nor execute them.
In another hand, IFRAMEr is looking for such tags on your pages and replaces them with IFRAMEs it generates on fly. 

## Supported browsers

Currently it supports IE6+, FF3.5+, and rest of the modern browsers for Linux, Windows and Mac. 

## Google Analytics
As a bonus IFRAMEr automatically provides [Universal Google Analytics Web Tracker](https://developers.google.com/analytics/devguides/collection/analyticsjs/) (ga function) from the page into widget's IFRAME.

## License
MIT.

---
_Source: https://npm.io/package/iframer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
