func RequireLazy(path string) func() error {
	var (
		once sync.Once
		err  error
	)
	return func() error {
		once.Do(func() {
			err = Require(path)
		})
		return err
	}
}
RequireLazy is the same as Require, but returns a function that will load the file on the first call.
package require
import (
	"errors"
	"strings"
	"sync"
	"github.com/dennwc/dom"
	"github.com/dennwc/dom/js"
)
var required = make(map[string]error)
func appendAndWait(e *dom.Element) error {
	errc := make(chan error, 1)
	e.AddEventListener("error", func(e dom.Event) {
		errc <- js.NewError(e)
	})
	done := make(chan struct{})
	e.AddEventListener("load", func(e dom.Event) {
		close(done)  
	})
	dom.Head.AppendChild(e)
	select {
	case err := <-errc:
		return err
	case <-done:
	}
	return nil
}
func Require(path string) error {
	if strings.HasSuffix(path, ".css") {
		return Stylesheet(path)
	} else if strings.HasSuffix(path, ".js") {
		return Script(path)
	}
	return errors.New("the file should have an extension specified (or '#.ext')")
}
func Stylesheet(path string) error {
	if err, ok := required[path]; ok {
		return err
	}
	s := dom.NewElement("link")
	v := s.JSValue()
	v.Set("type", "text/css")
	v.Set("rel", "stylesheet")
	v.Set("href", path)
	err := appendAndWait(s)
	required[path] = err
	return err
}
func Script(path string) error {
	if err, ok := required[path]; ok {
		return err
	}
	s := dom.NewElement("script")
	v := s.JSValue()
	v.Set("async", true)
	v.Set("src", path)
	err := appendAndWait(s)
	required[path] = err
	return err
}
func MustRequire(path string) {
	err := Require(path)
	if err != nil {
		panic(err)
	}
}
func MustRequireValue(name, path string) js.Value {
	MustRequire(path)
	return js.Get(name)
}