Script Preparation code:
Tests:

Historical Performance Data aggregated from 5 community runs

Desktop Results:
Chrome 5 runs
trim()
12.3M/s
replace()
3.0M/s

Fastest: trim() (4.1x faster)

View exact numbers
  • trim(): 12,313,842 ops/sec
  • replace(): 2,995,373 ops/sec

Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.

Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results
  • Test case name Result
    trim()
    replace()

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 8 months ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:147.0) Gecko/20100101 Firefox/147.0
Firefox 147 on Windows
View result in a separate tab
trim()
734.2M/s
replace()
1.8M/s
View exact numbers
Test name Executions per second
trim() 734,192,448 Ops/sec
replace() 1,761,841 Ops/sec