Доброе утро! Решила заняться оптимизацией сайта. Вычитала, что скрипты лучше всего ставить в конец HTML документа, чтобы они не мешали грузиться странице. Посмотрела исходник своего сайта. Там один скрипт (от модуля simpleform2) расписан и вставлен перед стилями. Как мне сделать этот скрипт внешним, то есть этот код собрать в файл, а потом просто ссылку на скрипт поместить? проблема в том, что модуль сам выносит этот скрипт в файл шаблона. и таблицу стилей от модуля DJ Slider Image тоже хотелось бы сделать внешней.
кусочек кода файла шаблона:
...........................................................
<link rel="stylesheet" href="http://10.10.2.32/modules/mod_djimageslider/assets/style.css" type="text/css" />
<link rel="stylesheet" href="/media/com_acymailing/css/module_custom.css" type="text/css" />
<link rel="stylesheet" href="/media/system/css/modal.css" type="text/css" />
<link rel="stylesheet" href="/modules/mod_jflanguageselection/tmpl/mod_jflanguageselection.css" type="text/css" />
...............................................
Код скрипта от модуля simpleform2 из файла шаблона, который нужно перенести
<script type="text/javascript">
(function($){ window.addEvent('domready',function(){var Slider192 = new DJImageSlider({id: '192', slider_type: 0, slide_size: 156, visible_slides: 10, show_buttons: 0, show_arrows: 2, preload: 1},{auto: 0, transition: Fx.Transitions.Cubic.easeInOut, duration: 800, delay: 3800})}); })(document.id);
jQuery.noConflict();
jQuery(document).ready(function(){
jQuery("form#simpleForm2_939").bind("beforeSubmit",function() {
return false;
});
jQuery("form#simpleForm2_939").bind("submit",function() {
if(!document.getElementById("simpleForm2_939_wrap")){jQuery("#simpleForm2_939_submit").wrap("<span id='simpleForm2_939_wrap' />");}
simpleForm2_939_tmp = jQuery("#simpleForm2_939_wrap").html();
jQuery("#simpleForm2_939_wrap").html("<img src=\"http://10.10.2.32/modules/mod_simpleform2/images/loading.gif\" alt=\"Loading...\" title=\"Loading...\" />");
jQuery(this).ajaxSubmit(function(data) {
var key = data.substring(0,1);
var text = data.substring(1);
var captcha = jQuery("#captcha_simpleForm2_939");
captcha.click();
if(key=="="){
jQuery("form#simpleForm2_939").html(text);
}
else if(key=="!"){
jQuery("#simpleForm2_939_wrap").html(simpleForm2_939_tmp);
alert(text);
}
else{
jQuery("#simpleForm2_939_wrap").html(simpleForm2_939_tmp);
alert(text);
}
}
);
return false;
});
});
jQuery.noConflict();
jQuery(document).ready(function(){
jQuery("form#simpleForm2_789").bind("beforeSubmit",function() {
return false;
});
jQuery("form#simpleForm2_789").bind("submit",function() {
if(!document.getElementById("simpleForm2_789_wrap")){jQuery("#simpleForm2_789_submit").wrap("<span id='simpleForm2_789_wrap' />");}
simpleForm2_789_tmp = jQuery("#simpleForm2_789_wrap").html();
jQuery("#simpleForm2_789_wrap").html("<img src=\"http://10.10.2.32/modules/mod_simpleform2/images/loading.gif\" alt=\"Loading...\" title=\"Loading...\" />");
jQuery(this).ajaxSubmit(function(data) {
var key = data.substring(0,1);
var text = data.substring(1);
var captcha = jQuery("#captcha_simpleForm2_789");
captcha.click();
if(key=="="){
jQuery("form#simpleForm2_789").html(text);
}
else if(key=="!"){
jQuery("#simpleForm2_789_wrap").html(simpleForm2_789_tmp);
alert(text);
}
else{
jQuery("#simpleForm2_789_wrap").html(simpleForm2_789_tmp);
alert(text);
}
}
);
return false;
});
});
window.addEvent("domready", function() {
SqueezeBox.initialize({});
$$("a.modal").each(function(el) {
el.addEvent("click", function(e) {
new Event(e).stop();
SqueezeBox.fromElement(el);
});
});
});
</script>
Код таблицы стилей от модуля DJ Slider Image из файла шаблона, который нужно перенести
<style type="text/css">
<!--
/* Styles for DJ Image Slider with module id 192 */
#djslider-loader192 {
margin: 0 auto;
position: relative;
height: 46px;
width: 1544px;
}
#djslider192 {
margin: 0 auto;
position: relative;
height: 64px;
width: 1544px;
display: none;
}
#slider-container192 {
position: absolute;
overflow:hidden;
left: 0;
top: 0;
height: 46px;
width: 1544px;
}
#djslider192 ul#slider192 {
margin: 0 !important;
padding: 0 !important;
border: 0 !important;
}
#djslider192 ul#slider192 li {
list-style: none outside !important;
float: left;
margin: 0 !important;
border: 0 !important;
position: relative;
height: 64px;
width: 156px;
background: none;
overflow: hidden;
}
#slider192 li img {
width: 140px;
height: auto;
border: 0 !important;
}
#slider192 li a img, #slider192 li a:hover img {
border: 0 !important;
}
/* Slide description area */
#slider192 .slide-desc {
position: absolute;
bottom: 0px;
left: 0px;
width: 140px;
}
#slider192 .slide-desc-in {
position: relative;
}
#slider192 .slide-desc-bg {
position:absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
#slider192 .slide-desc-text {
position: relative;
}
#slider192 .slide-desc-text h3 {
display: block !important;
}
/* Navigation buttons */
#navigation192 {
position: relative;
top: 24px;
margin: 0 -24px;
text-align: center !important;
}
#prev192 {
cursor: pointer;
display: block;
position: absolute;
left: 0;
}
#next192 {
cursor: pointer;
display: block;
position: absolute;
right: 0;
}
#play192,
#pause192 {
cursor: pointer;
display: block;
position: absolute;
left: 47%;
top: -99999px;
}
#cust-navigation192 {
position: absolute;
top: 10px;
right: 10px;
z-index: 15;
display: none;
}
-->
</style>