Jump to content

Backend JS performance


Recommended Posts

Hi,

 

may be wrong forum but i didn`t find better, 

 

we got some problem with admin script. Our store has a lot of features, and changing language in admin product tab became too slow. 

 

So we look into JS (admin.js) and found

	$('.translatable').each(function() {
		$(this).find('.lang_' + id_language_new)
			.show()
			.siblings('div:not(.displayed_flag):not(.clear)').hide();
		$('.language_current').attr('src', '../img/l/' + id_language_new + '.jpg');
	});

Changeing src for image takes too many time, but the question why show/hide works in current context (for current element in loop), and flag change for every field. So little changes makes it faster:

$('.translatable').each(function() {
		$(this).find('.lang_' + id_language_new)
			.show()
			.siblings('div:not(.displayed_flag):not(.clear)').hide();
		$(this).find('.language_current').attr('src', '../img/l/' + id_language_new + '.jpg');
	});
Edited by Newb (see edit history)
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...