Skip to content

Commit 152b1a2

Browse files
committed
remove wiki section on big docs, cascadia is now almost as fast as workarounds
1 parent 9043fe2 commit 152b1a2

File tree

1 file changed

+0
-23
lines changed

1 file changed

+0
-23
lines changed

doc/tips.md

-23
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,5 @@
11
# Tips and tricks
22

3-
## Manipulate Big Documents
4-
5-
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.
6-
7-
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.
8-
9-
For example:
10-
11-
```
12-
doc, err := goquery.NewDocumentFromReader(bigDocument)
13-
if err != nil {
14-
log.Fatal(err)
15-
}
16-
17-
// this could be much slower...
18-
sel := doc.Find("#bigtable tr:nth-child(1) td")
19-
20-
// than this:
21-
sel := doc.Find("#bigtable tr").First().Find("td")
22-
```
23-
24-
Other indexes in an `:nth-child(x)` can be translated to `sel.Eq(x)`.
25-
263
## Handle Non-UTF8 html Pages
274

285
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):

0 commit comments

Comments
 (0)