Closed Bug 672064 Opened 13 years ago Closed 13 years ago

twitter-text.js is slow to load in Firefox

Categories

(Core :: JavaScript Engine, defect)

8 Branch
x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla10

People

(Reporter: sayrer, Unassigned)

References

Details

Attachments

(3 files)

160.01 KB, application/x-javascript
Details
28.21 KB, application/x-javascript
Details
521 bytes, text/html
Details
I was playing around with this file this morning and noticed that the latency was really bad in Firefox 5 and 8. I narrowed it down to the time need to create a bunch of regular expressions. Will attach a testcase. Here are the times:

Firefox 8:      1450ms
WebKit Nightly: 150ms
Chrome 12:      20ms

Since we're sharing a regex implementation with WebKit, I am puzzled by the disparity here. Perhaps we are eagerly compiling each regex and they are doing so lazily. I ruled out network traffic by placing timers directly in the source (attached test is different, so as not to perturb the original file).
Attached file jquery dependency
Attached file twitter-text.js
Attachment #546343 - Attachment mime type: text/plain → application/x-javascript
Attached file Test case
Source repo is here:

https://github.com/twitter/twitter-text-js

Poking around twitter.com, I see that this file does get used, albeit an earlier version with fewer regexes to run. 

(Also CCing oliver@apple in case he wants to file a bug on JSC being an order of magnitude slower than V8 here)
https://gist.github.com/1086653

Here's a patch that speeds up the load in all browsers, in the WebKit bug Oliver points out that I didn't Shark it yet so it could be something else.
The issue was a really long regex. They fixed it on another branch by using character ranges instead.

https://github.com/twitter/twitter-text-js/commit/672cf1b17069712cb3a674c73f8a92b21669ac1b
673274
Making the dependency more specific. Note the reduction in bug 673188 comment 35.
Depends on: 673188
No longer depends on: 673274
HTML test case shows 9ms in nightlies for me.
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla10
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: