public function requireJs()
    {
        $scripts = $this->dispatcher->scripts('script', $this->assets, $this->path);

        $required = [];
        $string   = '';
        if (isset($this->assets['script'])) {
            foreach ($this->assets['script'] as $js) {
                if (!is_null($require = array_get($js, 'attributes.require'))) {
                    $required["'" . implode("','", $require) . "'"][] = $js['source'];
                }
            }


            $idx = 0;
            foreach ($required as $names => $scripts) {
                $require = "require([$names],function(){ " . "require(['" . implode("','", $scripts) . "'],function(){ :replace })" . "  });";
                if ($idx > 0) {
                    $string = str_replace(':replace', $require, $string);
                } else {
                    $string = $require;
                }
                ++$idx;
            }
        }

        $inlines = implode('', $this->dispatcher->scripts('inline', $this->assets, $this->path));

        $string = !strlen($string) ? $inlines : str_replace(':replace', $inlines . $this->afterLoad(), $string);


        $require = "['" . implode("','", $scripts) . "']";
        return $this->requireInline($require, $string);
    }