Answer the question
In order to leave comments, you need to log in
Big load on the browser when jquery is enabled?
Good afternoon. Please tell me how to solve this problem. Installed a magnifying glass plugin for images on the site. Everything connects and works, but since this is an online store, there can be up to 20 pictures on one page, and when the mouse is hovered over one of the images, the function for the entire page is launched. How can it be limited to only one picture? Pointed - the picture loaded - the function was connected - the mouse was removed - it turned off and so on in a circle ...
here is the function I could register to enable the library:
<script type=\'text/javascript\'><br/>
$(document).ready(function(){<br/>
$(\'#zoom1\').hover(function(){<br/>
$.getscript(\'js/cloud-zoom.1.0.2.min.js\', function(){<br/>
testAjax();<br/>
});<br/>
})<br/>
});<br/>
</script>
Answer the question
In order to leave comments, you need to log in
It looks like your code is loading "Cloud Zoom" from the Web (getscript) on every hover , which in itself can create a huge load:
$(document).ready(function(){
$('#zoom1').hover(function(){
$.getscript('js/cloud-zoom.1.0.2.min.js', function(){
testAjax();
});
});
});
$(function(){
$.getscript('js/cloud-zoom.1.0.2.min.js', function(){
$('#zoom1').hover(function(){
testAjax();
});
});
});
$('.cloud-zoom, .cloud-zoom-gallery').unbind();
$('.cloud-zoom, .cloud-zoom-gallery').CloudZoom();
$(document).ready(function () {
$('.cloud-zoom, .cloud-zoom-gallery').CloudZoom()
});
$('.cloud-zoom, .cloud-zoom-gallery').hover(function(){
$(this).CloudZoom();
});
$('.cloud-zoom, .cloud-zoom-gallery').addClass('CloudZoomNotRunning').hover(function(){
var $this = $(this);
if ($this.is('.CloudZoomNotRunning')){
$this.CloudZoom().removeClass('CloudZoomNotRunning');
};
});
And why hang up on hover the download of the entire script?
1. In any case, the script should only be loaded once per page.
2. After building (and again after rebuilding) the list of images on Ajax, the initialization function must be called again. To do this, you need to look at the source. If I'm not mistaken, then this one:
$('.cloud-zoom, .cloud-zoom-gallery').CloudZoom();
I don’t understand where Ajax and the magnifying glass have to do with it, well, let the directory be loaded by Ajax, upon loading (onload callback) do $(catalog).CloudZoom(); and so every time. And why, when hovering, load the plugin, I did not understand.
without getscript, it doesn't start at all, since the header doesn't interact with the ajax directory at all.
The main problem is that the script is launched when you hover the mouse over all the images at once ...
Because of this, the browser starts to slow down very much. And I would like
only one specific image to be launched on hover, and so with each image ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question