func (f *Fragment) Links() []*html.Node {
	return f.head
}
Links returns the new nodes that go in the head via
the LINK HTTP header entity.
package fragments
import (
	"bytes"
	"strconv"
	"strings"
	"sync"
	"time"
	"github.com/PuerkitoBio/goquery"
	"github.com/gofiber/fiber/v2"
	"github.com/google/uuid"
	"github.com/valyala/fasthttp"
	"golang.org/x/net/html"
	"golang.org/x/net/html/atom"
)
type HtmlFragment struct {
	doc *goquery.Document
	sync.RWMutex
}
func NewHtmlFragment(root *html.Node) (*HtmlFragment, error) {
	h := new(HtmlFragment)
	h.doc = goquery.NewDocumentFromNode(root)
	return h, nil
}
func (h *HtmlFragment) Fragment() *goquery.Document {
	return h.doc
}
func (h *HtmlFragment) Fragments() (map[string]*Fragment, error) {
	h.RLock()
	defer h.RUnlock()
	scripts := h.doc.Find("head script[type=fragment]")
	fragments := h.doc.Find("fragment").AddSelection(scripts)
	ff := make(map[string]*Fragment)
	fragments.Each(func(i int, s *goquery.Selection) {
		f := FromSelection(s)
		if !f.deferred {
			ff[f.ID()] = f
		}
	})
	return ff, nil
}
func (h *HtmlFragment) Html() (string, error) {
	h.RLock()
	defer h.RUnlock()
	html, err := h.doc.Html()
	if err != nil {
		return "", err
	}
	return html, nil
}
func (d *HtmlFragment) AppendHead(ns ...*html.Node) {
	head := d.doc.Find("head")
	head.AppendNodes(ns...)
}
type Fragment struct {
	deferred bool
	fallback string
	method   string
	primary  bool
	src      string
	timeout  int64
	id  string
	ref string
	statusCode int
	head       []*html.Node
	f *HtmlFragment
	s *goquery.Selection
}
func FromSelection(s *goquery.Selection) *Fragment {
	f := new(Fragment)
	f.s = s
	src, _ := s.Attr("src")
	f.src = src
	fallback, _ := s.Attr("fallback")
	f.fallback = fallback
	method, _ := s.Attr("method")
	f.method = method
	timeout, ok := s.Attr("timeout")
	if !ok {
		timeout = "60"
	}
	t, _ := strconv.ParseInt(timeout, 10, 64)
	f.timeout = t
	id, ok := s.Attr("id")
	if !ok {
		id = uuid.New().String()
	}
	f.id = id
	ref, _ := s.Attr("ref")
	f.ref = ref
	deferred, ok := s.Attr("deferred")
	f.deferred = ok && strings.ToUpper(deferred) != "FALSE"
	primary, ok := s.Attr("primary")
	f.primary = ok && strings.ToUpper(primary) != "FALSE"
	f.head = make([]*html.Node, 0)
	return f
}
func (f *Fragment) Src() string {
	return f.src
}
func (f *Fragment) Fallback() string {
	return f.fallback
}
func (f *Fragment) Timeout() time.Duration {
	return time.Duration(f.timeout) * time.Second
}
func (f *Fragment) Method() string {
	return f.method
}
func (f *Fragment) Element() *goquery.Selection {
	return f.s
}
func (f *Fragment) Deferred() bool {
	return f.deferred
}
func (f *Fragment) Primary() bool {
	return f.primary
}