try { var $ = require('jquery'); } catch (err) { } $( function () { $.fn.extend({ boxer: function (cls, pos) { var $this = $(this); if (cls === 'remove') { $this.children('.foorj-boxer').remove(); } else { $this.children('.foorj-boxer').remove(); var $b = $( $('#foorj_boxer_template').html() ); if (cls) { $b.addClass(cls) .children('.boxer-box').addClass(cls); } if (pos === 'prepend') { $this.prepend($b); } else { $this.append($b); } } } }); });