From the MDN docs for the standard setPrototypeOf function as well as the non-standard __proto__ property: Mutating the [[Prototype]] of an object, no matter how this is accomplished, is strongly discouraged, because it is very slow and unavoidably slows down subsequent execution in modern JavaScript implementations. Using Function.prototype to add properties is the way to add member functions to javascript
Tag: performance
NodeJS: Would App Run Faster if Freeze Objects?
Most of my objects/functions do not change. Would the application run faster if I freeze most of the objects via Object.freeze(object)? Or will it make no difference at all? Answer Freezing (and sealing) causes a signficant performance hit instead of a gain across various browsers. Just take a look at some of the jsperf benchmarks. EDIT: Here’s the relevant issue
Fastest and lightest way to get the current time in milliseconds with JS Date object
There are different ways to get the current time in milliseconds with Date object: Assuming that you don’t need to create an object and just need a current time in milliseconds, which one would be the most effective one? In terms of performance. EDIT: I understand most devs wouldn’t care about this, but it may matter when you work in
Jquery form submission not being triggered
I’m new to JavaScript. I have been trying to design some code which geocodes a location when a search button is hit and the submits the form if successful. To make it to slightly more complicated, if an option from the autosuggest is selected, it also geocodes it even before the search button is hit. This all seems to work,
Performance with infinite scroll or a lot of dom elements?
I have a question on a big # of dom elmenets and performance. Let’s say I have 6000 dom elements on a page and the number of the elements can be increased as a user interact with the page (user scrolls to create a new dom element) like twitter. To improve the performance of the page, I can think of
Put javascript and css inline in a single minified html file to improve performance?
A typical website consists of one index.html file and a bunch of javascript and css files. To improve the performance of the website, one can: Minify the javascript and css files, to reduce the file sizes. Concatenate the javascript files into one file and similar for the css files, to reduce the number of requests to the server. For commonly
Who is faster: PEG or GLR?
I’m trying to create some kind of lint tool for the C/AL programming language. So basically I need to perform syntax and lexical analysis against the source code. I’ve planned to write parser from the scratch, but then discovered that there are a lots of tools helping generate these parsers automatically. I need performance, since checking 20 megabytes of code
Should CSS always precede JavaScript?
In countless places online I have seen the recommendation to include CSS prior to JavaScript. The reasoning is generally, of this form: When it comes to ordering your CSS and JavaScript, you want your CSS to come first. The reason is that the rendering thread has all the style information it needs to render the page. If the JavaScript includes
Are JavaScript Arrays actually implemented as arrays?
The difference between a JavaScript Array, and Object is not very big. In fact it seems Array mainly adds the length field, so you can use both Arrays and Objects as numeric arrays: So my questions is, in popular JavaScript engines (V8, JavaScriptCore, SpiderMonkey, etc.), how is this handled? Obviously we do not want our arrays to be actually stored
Track mouse speed with JS
What’s the best way to track the mouse speed with plain JS/JQuery? I’d like to track how fast a user moves the mouse in all directions (up/down/left/right). Answer Sparklines has a nifty example of tracking mouse movement and graphing it. Their code is available in the source of their site starting at line 315. Simple and effective. Here is the