Stuck developing a new library module for "vminpoly". "Drupal.behaviors" confusion I think this could be really useful to the masses. I've so far not found a alternative. If you know of one, please do advise. 

My use case is having a banner with a height of 85% of the viewport. The new vh, vw and vmin length units in CSS are great for this. Except they don't work in all browsers and devices. 

The vminpoly library looks like a great solution. At window resize time, it generates CSS code for the 'px' equivalents and appends it in a 'style' element at the end of the 'head' element. The generated code respects media queries.

On their demo the JS part of the source code, in the footer, looks like this:

&lt;script type="text/javascript"&gt;
      if (!Array.prototype.filter)
      {
        Array.prototype.filter = function(fun /*, thisp*/)
        {
          var len = this.length;
          if (typeof fun != "function")
            throw new TypeError();

          var res = new Array();
          var thisp = arguments[1];
          for (var i = 0; i &lt; len; i++)
          {
            if (i in this)
            {
              var val = this[i]; // in case fun mutates this
              if (fun.call(thisp, val, i, this))
                res.push(val);
            }
          }

          return res;
        };
      }
    &lt;/script&gt;
    &lt;script src="tokenizer.js"&gt;&lt;/script&gt;
    &lt;script src="parser.js"&gt;&lt;/script&gt;
    &lt;script src="vminpoly.js"&gt;&lt;/script&gt;


So being as there isn't much to the module and in the interest of being complete, here are my files:

vminpoly.info

name = Vminpoly
description = Adds the vminpoly javascript plugin. It adds support to allow the use of vw,vh/vmin units in your theme.
core = 7.x
dependencies[] = libraries


vminpoly.module

&lt;?php

/**
 * Implements hook_libraries_info().
 */
function vminpoly_libraries_info() {
  $libraries = array();
  $libraries['vminpoly'] = array(
    'name' =&gt; 'Vminpoly',
    'vendor url' =&gt; 'https://github.com/saabi/vminpoly',
    'download url' =&gt; 'https://github.com/saabi/vminpoly',
    'version callback' =&gt; 'short_circuit_version',
    'files' =&gt; array(
      'js' =&gt; array(
        'tokenizer.js',
        'parser.js',
        'vminpoly.js',        
      ),
    ),
  );

  return $libraries;
}


/**
* Short-circuit the version argument.
*/
function short_circuit_version() { 
  return TRUE;
}

/**
* Load all files
*/
drupal_add_js('if (!Array.prototype.filter) { Array.prototype.filter = function(fun /*, thisp*/) { var len = this.length; if (typeof fun != "function") throw new TypeError(); var res = new Array(); var thisp = arguments[1]; for (var i = 0; i &lt; len; i++) { if (i in this) { var val = this[i]; if (fun.call(thisp, val, i, this)) res.push(val); } } return res; }; }', array('type' =&gt; 'inline'));
$name = 'vminpoly';
libraries_load($name);


I'm sure this will be of help to others, maybe even you. 

The question is what is wrong with it. I'm pretty confident (famous last words) that everything is as it should be, except the vminpolydrupal.js file. I'm sure its my lack of understanding when it comes to behaviours and tbh JS generally. I feel as though "context" needs to be added to their code snippet somewhere. 

I'm out of my comfort zone and learning. Please help...
So I had a few problems with this. First of all my .module file defined a library because that felt like the proper way to do it. However I received errors in the console and needless to say that it didn't work. After Googling the error I found out that it happens when everything is in the head.

So I removed the library implementation. Then the script itself didn't work. Again after searching on Google I found a fork of it where the guy had fixed those errors. This can be found at: https://github.com/gfaceless/vminpoly

I created a directory called lib, then placed parse-css.js &amp; vminpoly.js in it. 

My .module file became: 

&lt;?php

/**
* Load all files / JS
*/

drupal_add_js('if (!Array.prototype.filter) { Array.prototype.filter = function(fun /*, thisp*/) { var len = this.length; if (typeof fun != "function") throw new TypeError(); var res = new Array(); var thisp = arguments[1]; for (var i = 0; i &lt; len; i++) { if (i in this) { var val = this[i]; if (fun.call(thisp, val, i, this)) res.push(val); } } return res; }; }', array('type' =&gt; 'inline', 'scope' =&gt; 'footer'));
drupal_add_js(drupal_get_path('module', 'vminpoly') . '/lib/parse-css.js', array('scope' =&gt; 'footer'));
drupal_add_js(drupal_get_path('module', 'vminpoly') . '/lib/vminpoly.js', array('scope' =&gt; 'footer'));


Also removed dependencies[] = libraries from the .info. Lastly, for me it didn't kick in unless I aggregated my CSS files.

Hope this helps others. Now my vh, vw and vmin length units work across browsers. Happy days!