Tags
array bash benchmark cli compose compose key configuration css diy editorial firefox fixes gotcha hack hardware html5 input javascript jquery jsperf keyboard linux mouse multi touch multitouch nginx opera performance preferences prototype ruby sameheight snippet special characters ssh style syntax touchpad touch pad trackpad track pad ubuntu w3c web standards wiiCategories
-
Recent Posts
Recent Comments
- Lashell on Defining Functions Inline Is Just Fine
- Christian Iversen on JavaScript Performance: Iterating over Arrays with Holes
- force on JavaScript Performance: Iterating over Arrays with Holes
- Christian Iversen on JavaScript Performance: Iterating over Arrays with Holes
- force on Delete a Line from a File by Its Line Number
Archives
Meta
Category Archives: javascript
Depaginate Phoronix Articles
I sketched this for Phoronix, but you could easily adapt it to any site that uses pagination. I think it’s an interesting problem, so if you want to see another site depaginated, just ask me in a comment and I’ll … Continue reading
Posted in javascript, quickies
Tagged depaginate, depagination, javascript, jquery, paginate, pagination, phoronix, plugin, user script
Leave a comment
JavaScript Performance: Iterating over Arrays with Holes
I was sketching some code that basically took some data from a database and cached it in an array to be repeatedly reused. Conveniently, each row from the database had a unique ID, so I could use that as an … Continue reading
Posted in javascript, Uncategorized
Tagged array, benchmark, hole, iteration, javascript, jsperf, loop, undefined
3 Comments
Defining Functions Inline Is Just Fine
I put together this jsperf to see if there’s a difference between defining your function and then using it or defining it inline when looping with jQuery.each. You can try it yourself if you like, but here are the results: … Continue reading
JavaScript Strings: instanceof vs. typeof
I’ve discovered some really interesting (read as “horrible”) behavior in Safari 5 and Internet Explorer 9. I was using this with great success in Chrome and Firefox. if (typeof this === ‘string’) { doStuffWith(this); } Then I test … Continue reading
Posted in javascript
Tagged bug, chrome, firefox, gotcha, ie9, instanceof, internet explorer, javascript, quirk, savari, string, strings, typeof
Leave a comment
That’s Profiling!
I want to see if one string exists in another, case-insensitive. What’s faster? Making the strings both lower case then comparing them with String.match? Comparing the first string to a case-insensitive regular expression of the other? Making them both lower … Continue reading
Are You Still There?
A scenario: you want to update some content on your page periodically, but you don’t want to waste requests, resources, cycles, etc. on running your script while the user is obviously not interacting with the page. What do you do? … Continue reading
Posted in javascript
Tagged awake, blur, focus, interval, javascript, jquery, periodic, setinterval, sleep, user interface
Leave a comment
Add Stable Merge Sort to Array and jQuery Prototypes
Some browsers’ JavaScript implementations don’t implement a stable sort, but stable sorting can be so handy if you want to, say, sort a table by multiple columns. So here’s a quick and easy way to add an efficient, stable merge … Continue reading
Posted in javascript
Tagged array, extend, javascript, jquery, merge sort, mergesort, prototype, sort, sorting, stable sort, stable sorting
Leave a comment
Beyond setTimeout: Delay Your JavaScript with Closures
Have you ever wanted to delay something with JavaScript? So, of course, you look to window.setTimeout. But maybe this is interactive, or you want to be able to interrupt it? Then you save a reference to it, and you pass … Continue reading
Posted in javascript
Tagged accumulator, closure, delay, function object, functional, functionoid, functor, javascript, state, timeout
Leave a comment
Framework-Free Automatic Brush Loading for SyntaxHighlighter
Update: Have you heard of SyntaxHighlighter? It’s pretty cool. I like that it adds little controls for popping the code out into a new window in plain text and that it has line numbers. However, I think that these days … Continue reading
Posted in javascript, scripts
Tagged framework free, github, highlight, highlighting, javascript, jquery, no framework, prototype, syntax, syntax highlighter, syntaxhighlighter
Leave a comment