5 ms·
Man... this is full of crazy talk: For better performance you can use direct functions like $.ajax() than $.get(), $.getJSON(), $.post() because the last ones
by wycats 15y ago
Man... this is full of crazy talk:
For better performance you can use direct functions like $.ajax() than $.get(), $.getJSON(), $.post() because the last ones are shortcuts that call the $.ajax() function.
I've never written an app where the overhead of $.getJSON has been any kind of bottleneck.
Don’t forget about using .data() function to store stuff for your elements
How is this a performance tip?
Sometimes it’s faster to use $(window).load() than $(document).ready() because the last one occurs before all the DOM elements are downloaded
Say what?
If you want to save some bits on compressing your js plugin – replace the $(document).onready() event
Saving bits! The favorite optimization bikeshed of the JavaScript glitterati.
The best way to test a Javascript code is the human way :D But, you still can use some automated tools like Selenium, Funcunit, QUnit and QMock to test your code
I hope this is a joke.
The new HTML 5 standard comes with a lighter DOM structure in mind
What?
When styling a few elements it is best to simply use jQuery’s css() method, however when styling 15 or more elements it is more efficient to append a style tag to the DOM.
Or, if you're worried about performance and reusability, you could use classes and use addClass and removeClass.
- HoLyVieR 15y agoYou forgot my personnal favorite : "Lazy load content for speed and SEO benefits" This guy either works at Google or doesn't have a clue of what he's saying. SEO is already black magic. That kind of claim requires heavy evidence which are simply not there.
- chrisguitarguy 15y agoHardly black magic. But there has been a lot of theories tossed around about page load speed influencing rankings. So it's understandable why he things that -- and google's addition of page speed to analytics hasn't helped stop the myth. Unfortunately, there's not a lot of solid evidence about it (yet).
- deleted 15y ago[deleted]
- leeoniya 15y agoyeah, lots of misinformation in the article :(
- kirbysayshi 15y agoI'm glad I'm not the only one. Basically, this article should be retitled, "jQuery Good Practices", and only then after most points are either removed or revised. Is it worth an itemized address? It's nice to have a list of good things to do, but only when they're actually good... and can be explained as to WHY they're good. Having "cheat sheets" attached to it also lends credence where there should be none.
- d_r 15y agoSome of these exemplify "premature optimization" and will clutter code with no discernible benefit. I remember some days ago, in the days of PHP, there were heated debates about whether or not using single or double quotes for strings makes code faster. As with most development, use good practices. But then at the end of the day, profile your application to find the actual bottlenecks.