Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractClasses ¶
ExtractClasses extracts class names from a provided CSS string. It returns a sorted, unique list of class names without the leading dot, ensuring that each class name is valid according to CSS naming conventions. If any error occurs during the extraction, an error is returned alongside an empty slice.
func ExtractClassesFromFile ¶
ExtractClassesFromFile reads the CSS file specified by the given path and extracts a sorted list of unique class names found within it. If reading the file fails, it returns an error. Otherwise, it returns a slice of class names without leading dots and ensures that each class name is valid according to CSS naming conventions.
Types ¶
type Finder ¶
type Finder struct {
// contains filtered or unexported fields
}
Finder locates unused CSS classes within a website starting from a given URL up to a specified limit of pages. It concurrently crawls the site, respects cancellation via context, and logs its progress using a structured logger. Finder provides the ability to identify classes that are not being utilized in any of the visited pages, helping in the optimization and cleanup of CSS resources. It operates with a customizable degree of concurrency, determined by available CPU resources, to efficiently process multiple pages in parallel.
func New ¶
New initializes a new Finder with the specified root URL and page limit, logging under the "Finder" namespace. It returns a pointer to the newly created Finder and any error that occurred during its creation, such as an invalid root URL.
func (*Finder) FindUnused ¶
FindUnused identifies which of the provided CSS class names are not being used across the web pages within the scope defined by the root URL of the Finder instance. It traverses the website, starting from the root URL, and returns a slice of strings representing class names that appear to be unused. If an error occurs during the search process, it also returns an error detailing what went wrong.