You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Let a caller that already navigated collect the CSS of the page #5
Hi Bart! Joan here. I'm planning a CSS analysis for the CLI of WebPerf Snippets with css-analyzer, and I'd rather use css-scraper than write another collector. The design principles in the README are exactly what we need, especially preferring the shipped text over the CSSOM.
One thing gets in the way: scrape_css(page, url) calls page.goto() itself. Our CLI navigates on its own (CPU and network throttling, request headers, a storage state for pages behind a login, scripted interactions), and a second load would measure a different page.
The steps already exist in network-css.ts and dom-css.ts; only scrape_css is exported. Would you accept exporting them, so a caller can start tracking before its own navigation and collect afterwards? Something like:
import{track_css_responses,collect_css}from'@projectwallace/css-scraper'constresponses=track_css_responses(page)awaitpage.goto(url)// or whatever the caller does to load the pageconstsources=awaitcollect_css(page,responses)
collect_css would be the second half of scrape_css (collect_dom_css plus cross_check_network_responses), and scrape_css would become track, goto, collect, with no change for current users. The names are yours to pick, of course.
If the shape works for you, I'm happy to send a PR with tests. I also noticed two small things in the usage example of the README: the import reads @projectwallace/scrape-css instead of @projectwallace/css-scraper, and the last line reads css.source.css instead of css_source.css. I can fix them in the same PR or in a separate one, whichever you prefer.
Heeey, sorry, I missed the notification for this one. I really dig the idea and I think the API design is better that way, so I made it the default in the readme and exposed the API's as you suggested. Marked you as co-author of the commit in #8. Thanks for the great suggestion! Is the PR what you had in mind?
Activity
bartveneman commentedon Nov 2, 2026
Heeey, sorry, I missed the notification for this one. I really dig the idea and I think the API design is better that way, so I made it the default in the readme and exposed the API's as you suggested. Marked you as co-author of the commit in #8. Thanks for the great suggestion! Is the PR what you had in mind?