diff --git a/gallery.module b/gallery.module
index b6c86c424aa27acde12083520dfbeb97a183b270..39fdb5bdc278a55f2f71279449060fe1381259b1 100644
--- a/gallery.module
+++ b/gallery.module
@@ -207,7 +207,9 @@ function gallery_page() {
if (!$result['isDone']) {
list($title, $css, $javascript) = GalleryEmbed::parseHead($result['headHtml']);
- drupal_set_html_head(implode("\n",$javascript));
+ if (!empty($javascript)) {
+ drupal_set_html_head('');
+ }
drupal_set_html_head(implode("\n",$css));
// hack to cleanup matrix when embedded
drupal_set_html_head('');