jquery-pjax icon indicating copy to clipboard operation
jquery-pjax copied to clipboard

Fixes #453 : Keep strings in cache instead of jquery objects

Open klevron opened this issue 11 years ago • 7 comments

klevron avatar Dec 06 '14 23:12 klevron

https://github.com/defunkt/jquery-pjax/issues/453

klevron avatar Dec 06 '14 23:12 klevron

This might slow down navigation due to the extra overhead of HTML serialization and parsing, and might have other adverse side-effects as well. If you want to make a significant change like this happen in a library, you should try making a stronger case than just a pull request with no description.

Like, you might explore:

  1. Does this actually use less cache memory (something that you hinted at in the issue discussion)
  2. How does the performance of this compare to the previous approach on large pages?
  3. What could be some less invasive ways to solve the VIDEO problem loading/playing in background?

mislav avatar Dec 07 '14 00:12 mislav

Hello

Sorry, didn't add description here since discussion is in the issue...

About memory, don't have time to make a bench, but it's obvious, nodes will take more memory than simple strings.

About perfs : http://jsperf.com/jquery-clone-vs-html-construction Don't have time now, but it should be interesting to complete this bench with node inserts.

And about video bug, I tried a lot of things, it is the better and simplest way I found to solve it. So, is there any reason to keep jquery objects in cache ?

One caveat in using html() :

This method uses the browser's innerHTML property. Some browsers may not return HTML that exactly replicates the HTML source in an original document

klevron avatar Dec 07 '14 10:12 klevron

Some browsers may not return HTML that exactly replicates the HTML source in an original document

Yeah that's what I'm worried about. We can explore this direction, and I can definitely believe that HTML strings can make up less memory than storing nodes, but we'll need to perform some testing on real-world-looking pages with dozens or even hundreds of navigations between reloads and analyze how it affects performance stats.

mislav avatar Dec 08 '14 03:12 mislav

I'll try to build a bench in the week. We could also add an option to chose cache type, what do you think ?

klevron avatar Dec 08 '14 10:12 klevron

Little bench with more tags : http://jsperf.com/clone-vs-html-bench The difference is not so visible in chrome.

klevron avatar Dec 08 '14 16:12 klevron

On Mon, Dec 8, 2014 at 8:29 AM, Kevin LEVRON [email protected] wrote:

The difference is not so visible in chrome.

Thanks for making that bench. Interesting that the html() approach is just as fast or faster than cloning nodes.

mislav avatar Dec 09 '14 04:12 mislav