Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash vs Vanilla JS Test
(version: 0)
Comparing performance of:
Lodash vs Vanilla Js
Created:
3 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.4/lodash.min.js"></script>
Tests:
Lodash
const status = "ACCEPTED_ON_AUDIT"; for ( let i = 0; i < 100000; i++) { _.capitalize(status.split("_")) }
Vanilla Js
const status = "ACCEPTED_ON_AUDIT"; for ( let i = 0; i < 100000; i++) { status[0].toUpperCase() + status.slice(1).toLowerCase().split("_").join(" "); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Lodash
Vanilla Js
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Browser/OS:
Chrome 131 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Lodash
57.8 Ops/sec
Vanilla Js
65.4 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's dive into the world of JavaScript microbenchmarks. **What is being tested?** The benchmark measures the performance difference between using Lodash, a popular JavaScript utility library, and writing custom code without any libraries (also known as "vanilla" JavaScript). The test case compares the execution time of two identical operations: splitting a string, converting its first character to uppercase, and then joining the remaining characters with spaces. **Options being compared** There are two approaches being tested: 1. **Lodash**: Using Lodash's `capitalize` function, which takes a string as input and returns a new string with the first character capitalized and the rest in lowercase. 2. **Vanilla JavaScript**: Writing custom code to achieve the same result using string manipulation techniques. The test case uses two separate steps: splitting the string into an array of words, converting the first word to uppercase, and then joining the remaining words with spaces. **Pros and cons of each approach** **Lodash:** Pros: * Convenience: Lodash provides a pre-built function that makes the code more readable and easier to maintain. * Performance: Lodash's implementation is often optimized for performance, especially when compared to custom-written code. Cons: * Overhead: Including an external library adds overhead due to the need to load and initialize the library. * Dependence on library: The test case relies on Lodash being available in the browser or environment, which may not always be the case. **Vanilla JavaScript:** Pros: * No dependencies: This approach doesn't require any additional libraries, making it more portable and self-contained. * Control: By writing custom code, developers have full control over the implementation details. Cons: * Complexity: The custom code can become complex and harder to read, especially for users unfamiliar with string manipulation techniques. * Performance: Without optimization, custom-written code might not perform as well as Lodash's optimized implementation. **Library (Lodash)** Lodash is a popular JavaScript utility library that provides a wide range of functions for various tasks, such as array manipulation, string processing, and more. In this benchmark, Lodash's `capitalize` function is used to split the input string into words and capitalize the first word. **Special JS feature or syntax (none)** There are no special JavaScript features or syntaxes being used in this benchmark that require explanation. **Other alternatives** If you're looking for alternative approaches to writing custom code without Lodash, some options include: * Using `String.prototype.split()` and `String.prototype.toUpperCase()`, as shown in the Vanilla JavaScript test case. * Implementing a custom string processing function using loops and conditional statements. * Utilizing other utility libraries or frameworks that provide similar functionality to Lodash. Keep in mind that these alternatives might offer trade-offs in terms of performance, readability, or portability, depending on your specific use case and requirements.
Related benchmarks:
Native Undefined vs Lodash isUndefined
isFunction vs typeof function 6
isEmpty vs. vanilla
Lodash.js vs Native - empty
lodash noop vs new function
Comments
Confirm delete:
Do you really want to delete benchmark?