summaryrefslogtreecommitdiffstats
path: root/publisher/htmlElementsCollector.go
Commit message (Collapse)AuthorAge
* all: Run gofumpt -l -w .Bjørn Erik Pedersen2024-01-28
|
* publisher: Improve class collector for dynamic classesBjørn Erik Pedersen2023-07-19
| | | | | | | E.g. * AlpinesJS' :class="isTrue 'class1' : 'class2'" * And dynamic classes with colon in them, e.g. `hover:bg-white`
* Fix buildStats when tags and classes are disabledBjørn Erik Pedersen2023-07-03
| | | | Fixes #11202
* Rework the build.writeStats structBjørn Erik Pedersen2023-07-02
| | | | | | Mostly to make it easier to toggle on/off this feature from the env. See #11191
* Make build.writeStats a structBjørn Erik Pedersen2023-07-01
| | | | | | | | | | | | | So you can do ```toml [build.writeStats] tags = true classes = true ids = false ``` Fixes #11191
* Make the HTML collector parsing more robustBjørn Erik Pedersen2023-02-07
| | | | | | Most notably better handling self-closing elements Closes #10698
* Fix slow HTML elements collector for the pre caseBjørn Erik Pedersen2023-02-05
| | | | | | | | | | | | | | | ``` name old time/op new time/op delta ElementsCollectorWriterPre-10 25.2µs ± 1% 3.4µs ± 0% -86.54% (p=0.029 n=4+4) name old alloc/op new alloc/op delta ElementsCollectorWriterPre-10 624B ± 0% 142B ± 0% -77.18% (p=0.029 n=4+4) name old allocs/op new allocs/op delta ElementsCollectorWriterPre-10 16.0 ± 0% 6.0 ± 0% -62.50% (p=0.029 n=4+4) ``` Fixes #10698
* publisher: Make the HTML element collector more robustBjørn Erik Pedersen2021-05-19
| | | | Fixes #8530
* Revert "publisher: Make the HTML element collector more robust"Bjørn Erik Pedersen2021-05-19
| | | | This reverts commit ef0f1a726901d6c614040cfc2d7e8f9a2ca97816.
* Revert "publisher: Get the collector in line with the io.Writer interface"Bjørn Erik Pedersen2021-05-19
| | | | This reverts commit a9bcd38181ceb79afba82adcd4de1aebf571e74c.
* publisher: Get the collector in line with the io.Writer interfaceBjørn Erik Pedersen2021-05-17
| | | | As in: Do not retain the input slice.
* publisher: Make the HTML element collector more robustBjørn Erik Pedersen2021-05-17
| | | | Fixes #8530
* publisher: Remove some unreachable codeBjørn Erik Pedersen2021-04-20
|
* publisher: Some performance tweaks for the HTML elements collectorBjørn Erik Pedersen2021-04-20
|
* publisher: Exclude comment and doctype elements from writeStatsDirk Olbrich2021-04-20
| | | | | | | | | - Reorder code blocks - Rename cssClassCollectorWriter to htmlElementCollectorWriter, as it just collect html element information - Expand benchmark to test for minified and unminified content Fixes #8396 Fixes #8417
* publisher: Skip script, pre and textarea content when looking for HTML elementsBjørn Erik Pedersen2021-04-07
| | | | Updates #7567
* Trim whitespace in elements written to hugo_stats.jsonPavlo Matiash2021-02-01
| | | Fixes #7958
* all: Fix minor typosPhil Davis2020-12-16
|
* all: Format code with gofumptBjørn Erik Pedersen2020-12-03
| | | | See https://github.com/mvdan/gofumpt
* publisher: Fix memory usage in writeStatsBjørn Erik Pedersen2020-11-27
| | | | | | | | | | | | | | | ``` name old time/op new time/op delta ClassCollectorWriter-16 72.1µs ± 0% 32.3µs ± 0% -55.17% (p=0.029 n=4+4) name old alloc/op new alloc/op delta ClassCollectorWriter-16 85.9kB ± 0% 35.1kB ± 0% -59.16% (p=0.029 n=4+4) name old allocs/op new allocs/op delta ClassCollectorWriter-16 329 ± 0% 149 ± 0% -54.71% (p=0.029 n=4+4) ``` Fixes #7945
* publisher: Fix writeStats with quote inside quotesBjørn Erik Pedersen2020-09-28
| | | | Fixes #7746
* publisher: Collect transition attributes as classesBjørn Erik Pedersen2020-07-23
| | | | Fixes #7509
* publisher: Fix tag collector for nested table elementsBjørn Erik Pedersen2020-05-27
| | | | Fixes #7318
* Fix some missing JS class collector casesBjørn Erik Pedersen2020-04-27
| | | | Fixes #7216
* Fix class collector when running with --minifyBjørn Erik Pedersen2020-04-21
| | | | | | Also add a related stresstest. Fixes #7161
* Collect HTML elements during the build to use in PurgeCSS etc.Bjørn Erik Pedersen2020-04-09
The main use case for this is to use with resources.PostProcess and resources.PostCSS with purgecss. You would normally set it up to extract keywords from your templates, doing it from the full /public takes forever for bigger sites. Doing the template thing misses dynamically created class names etc., and it's hard/impossible to set up in when using themes. You can enable this in your site config: ```toml [build] writeStats = true ``` It will then write a `hugo_stats.json` file to the project root as part of the build. If you're only using this for the production build, you should consider putting it below `config/production`. You can then set it up with PostCSS like this: ```js const purgecss = require('@fullhuman/postcss-purgecss')({ content: [ './hugo_stats.json' ], defaultExtractor: (content) => { let els = JSON.parse(content).htmlElements; return els.tags.concat(els.classes, els.ids); } }); module.exports = { plugins: [ require('tailwindcss'), require('autoprefixer'), ...(process.env.HUGO_ENVIRONMENT === 'production' ? [ purgecss ] : []) ] }; ``` Fixes #6999