Answer the question
In order to leave comments, you need to log in
Which way to choose to optimize a very large page with a bunch of inputs?
Greetings.
There is a service page. It has many inputs, span with numbers, buttons. Buttons perform actions, for example:
$(selector).on('click', function(){// some code});
. As a result, about a thousand handlers. And there are more than one thousand of them. Obviously this needs to be rewritten to$('body').on('click', selector, function(){// some code});
Answer the question
In order to leave comments, you need to log in
It's not entirely clear what exactly you are doing and why you need to see all this bunch of data at the same time, but at first glance it looks like you need a normal search for all this data on the server side.
We still need to change something so that HTML does not weigh 80 megabytes and there are not 18,000 lines. A person will not read all these thousands of lines anyway.
Transferring rendering from the server side to the client will result in a performance degradation of 10 times with this amount of data.
It is necessary to solve the problem in several ways
1. In smarty2, refuse to include, switch to defun / fun plugin (if include is used)
2. In smarty3, try to reduce the number of functions if there are many and they are small
3. Minimize the generation of templates on the client side
4 Since the operator does not need everything at once, it is possible to break the interface into many small parts, and load them on demand. as finished html.
5. The problem of filling in the set of fields must be solved not through jQ. Here, the most correct way would be to cache links to nodes and iterate over them. Personally, I use my tools for this, in which caching is done out of the box
.
The maximum nodes that the browser digests should be kept in the region of 10-20K.
If you need any more consultations, it is better to write to me on Skype (in profile) or in a personal message.
1. jQuery Templates are deprecated and no longer supported. This must be taken into account. Their speed is not the worst, but it seems to be faster.
2. It will take a really long time to render - the client machine is most likely slower than the server. You can do two things: give the client pre-compiled templates (it doesn't make much sense if the templates are simple), and not render everything at once, but asynchronously in chunks of 5 of your lines.
3. You can replace pagination with "infinite" scrolling. Search to provide other means.
If the page problem is only in the search, then as mentioned above, you need to do a normal ajax search.
Either this task is somehow solved differently, but you need to know what all this is for.
18,000 lines? Still, it's overkill.
You can do asynchronous loading of the displayed content - and let the server deal with mass operations, it's just a spit for him. If you search using Ctrl-f, then generate a page with only id && name, and let prices be loaded “on demand”.
You can write a client in C#.
Surely some elements are repeated on the page for each line (I'm talking about these five inputs). Why not put them in a separate Popup, and store the data for individual elements in JS or in hidden? And it will be easier to give JSON data ...
There are a lot of optimization options, for starters, at least cache the generated templates in smart + optimize the layout. I once made 2 from 5 MB of html by simply renaming classes and minimizing the layout. It will no longer be 80 MB.
The problem needs to be solved in the other direction, and if in a year there will be 50,000 lines? Increase RAM on client machines? Convince the customer to make dynamic ajax tables - they will digest a million rows - github.com/clausshellsing/JqTable
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question