samtiria / nextgen-gallery

Automatically exported from code.google.com/p/nextgen-gallery
0 stars 0 forks source link

Useless javascript loaded #402

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hello. In nggallery.php I see this

wp_register_script('jquery-cycle', NGGALLERY_URLPATH 
.'js/jquery.cycle.all.min.js', array('jquery'), '2.88');
wp_enqueue_script('ngg-slideshow', NGGALLERY_URLPATH 
.'js/ngg.slideshow.min.js', array('jquery-cycle'), '1.05');

These 2 JS are included even when they are not needed for instance if you do 
not activate the slideshow.

Am I right or I miss something ? 

Original issue reported on code.google.com by simone.f...@gmail.com on 9 Aug 2011 at 4:02

GoogleCodeExporter commented 8 years ago
Well, with the constant NGG_SKIP_LOAD_SCRIPTS you are able to skip the script 
load and build your own conditional. You you need to check a couple of thing 
for conditionals load (header, widgets, content).

Original comment by alex.cologne on 9 Aug 2011 at 5:59

GoogleCodeExporter commented 8 years ago

Original comment by alex.cologne on 28 Aug 2011 at 8:42

GoogleCodeExporter commented 8 years ago
Hello. I was still thinking at this and here 2 points to consider

- Why do not also add a NGG_SKIP_LOAD_STYLE to avoid NGG to enqueue css ? (add 
it in load_styles() method for nggLoader class)

- I also add a patch. I've added a couple of condition to avoid load of useless 
JS/CSS if some flag are checked.

Let me know what you think about.

Original comment by simone.f...@gmail.com on 30 Dec 2011 at 9:50

GoogleCodeExporter commented 8 years ago
One more point. In a multisite installation if the plugin is not activated at 
network level there is no way to enable (and thus disable) the style for the 
gallery.

In other words there is no way to show the menu "Style" under the "Gallery" 
group.

Original comment by simone.f...@gmail.com on 3 Jan 2012 at 10:59

GoogleCodeExporter commented 8 years ago
Hi Simone,

there is no patch attached to this ticket, if you add the needed changes i will 
review them

Thanks
Alex

Original comment by alex.cologne on 4 Jan 2012 at 3:40

GoogleCodeExporter commented 8 years ago
Here we go with the patch

Original comment by simone.f...@gmail.com on 5 Jan 2012 at 10:11

Attachments:

GoogleCodeExporter commented 8 years ago
Ok, will review this

Original comment by alex.cologne on 5 Jan 2012 at 6:28

GoogleCodeExporter commented 8 years ago
When I apply this patch, my slide show wont load anymore. 

I just tried to revert back to the original file, and it starts loading again.

It has to do with the option galShowSlide. Which is only true if the option 
"Integrate slideshow" is enabled.

So in case you insert a slideshow short code without the possibility to switch, 
you will be missing the java script. 

/Kristian

Original comment by kristian...@gmail.com on 16 Jan 2012 at 6:43

GoogleCodeExporter commented 8 years ago
Well, just had the same issue here. Need to invest more time, but I think it's 
not possible to skip script load just because of an option. In the best case 
the full content need to be parsed in advance to decide if the page require a 
script or not.

maybe this can be done with a global variable which will be set to true, when a 
certain function will be called.

Original comment by alex.cologne on 17 Jan 2012 at 7:11