Skip to content

Commit

Permalink
chore: add screenshots and conclusion
Browse files Browse the repository at this point in the history
  • Loading branch information
David-Pena committed Aug 6, 2024
1 parent 3315377 commit a863ffc
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,17 @@ This repository contains a simple yet effective benchmarking tool to compare the

## 📸 Screenshot

![Benchmark Screenshot](/assets/screenshot.png)
![Benchmark Results Screenshot](/assets/screenshot-results.png)
![Benchmark Results Screenshot w 10_000](/assets/ss-results-10000.png)
![Benchmark Results Screenshot w 20_000](/assets/ss-results-20000.png)
![Benchmark Results Screenshot w 50_000](/assets/ss-results-50000.png)

## 📊 Conclusion

The benchmark results clearly indicate that **class selectors consistently outperform element selectors** in terms of speed when applying styles in JavaScript. As the number of HTML elements increases, the time difference between the two selector types becomes more pronounced. Specifically:

- With **10,000 HTML elements**, class selectors are approximately **17% faster** than element selectors.
- With **20,000 HTML elements**, class selectors are around **12% faster** than element selectors.
- With **50,000 HTML elements**, class selectors are about **18% faster** than element selectors.

> [!IMPORTANT]
> These findings suggest that using class selectors can lead to more efficient performance, especially in scenarios with a large number of elements. Therefore, for better performance in styling large-scale web applications **class selectors should be preferred** over element selectors.
Binary file removed assets/screenshot-results.png
Binary file not shown.
Binary file added assets/ss-results-10000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/ss-results-20000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/ss-results-50000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a863ffc

Please sign in to comment.