Web components are the shiny new thing on the horizon for web development. Sadly browser support is not just there, but it seems to be growing pretty quickly.
For an up-to-date overview, you can head over to caniuse.com for a summary.
So the most basic web component would look like this.
To use this element, this class has to be registered within the browser with a given alias.
Important here is, that all custom element aliases must contain a ‘-‘. Otherwise, it could lead to conflicts with existing HTML elements.
Now I can use this element by just adding a corresponding element to the DOM.
This concludes the basic structure of what has to be defined. Expanding on that, I wanted to add some actual content to my web component, to make it somewhat more useful.
Since this control is called hello-world, it should say “hello world” whenever it is injected into the DOM. To achieve this, I have to add a constructor to my class.
All this together in one HTML file would look like this.
If your browser supports it, the following iframe gets filled with the hello world control.
- embed a github commit log into markdown
- add jar to the classpath at runtime in jjs (the hacky way)
- doing objects in jjs
- read the content of a file in one line in jjs
- print something to the console in jjs
- using jjs under osx
- tracking virtual links with google analytics
- cloud-the-web - my new web project
- installing GLUEscript on debian squeeze 64bit