remove wiki section on big docs, cascadia is now almost as fast as workarounds

This commit is contained in:
Martin Angers
2016-08-31 12:22:11 -04:00
parent 9043fe2599
commit 152b1a2c8f
-23
View File
@@ -1,28 +1,5 @@
# Tips and tricks
## Manipulate Big Documents
Some CSS selectors are inherently slower than others, and when manipulating big documents (e.g. tables with thousands of rows), the performance may suffer. In particular, pseudo-classes such as `:nth-child` are slow, and while they are handy when manipulating smaller documents, they can be painful for bigger ones.
In those cases, it can be order of magnitudes faster to use a simpler CSS selector and use goquery methods to do the finer-grained filtering.
For example:
```
doc, err := goquery.NewDocumentFromReader(bigDocument)
if err != nil {
log.Fatal(err)
}
// this could be much slower...
sel := doc.Find("#bigtable tr:nth-child(1) td")
// than this:
sel := doc.Find("#bigtable tr").First().Find("td")
```
Other indexes in an `:nth-child(x)` can be translated to `sel.Eq(x)`.
## Handle Non-UTF8 html Pages
The `go.net/html` package used by `goquery` requires that the html document is UTF-8 encoded. When you know the encoding of the html page is not UTF-8, you can use the `iconv` package to convert it to UTF-8 (there are various implementation of the `iconv` API, see [godoc.org][iconv] for other options):