I found three connected scripts in the header and in the basement, each of which makes an http request. I decided to combine them into one file. As a result, the 2nd and 3rd scripts refuse to work.
Question: Tell me how to combine three javascript in one file to reduce http-requests?
Javascript files
1 script Site menu
function( $ ) { // меню var body = $( 'body' ), _window = $( window ); function() { var nav = $( '#primary-navigation, #secondary-navigation' ), button, menu; if ( ! nav ) { return; } button = nav.find( 'h1.menu-toggle, h2.menu-toggle' ); if ( ! button ) { return; } menu = nav.find( '.nav-menu' ); if ( ! menu || ! menu.children().length ) { button.hide(); return; } $( 'h1.menu-toggle' ).on( 'click.pixelcom', function() { nav.toggleClass( 'toggled-on' ); } ); $( 'h2.menu-toggle' ).on( 'click.pixelcom', function() { nav.toggleClass( 'toggled-oncat' ); } ); } } 2 script - Show hide div block
function look(type){ // скрыть показать param=document.getElementById(type); if(param.style.display == "none") param.style.display = "block"; else param.style.display = "none" } 3rd script Up to page header
function dd_scrolltotop(duration){// вверх duration = duration || 500 var rootel = (document.compatMode =="BackCompat")? document.body : document.documentElement if (rootel.scrollTop == 0) rootel = document.body var curscrolltop = rootel.scrollTop, scrolltimer, elapsedtime, starttime = new Date().getTime(), animatedegree = 0 var totaldis = curscrolltop clearTimeout(scrolltimer) function jumptop(){ elapsedtime = new Date().getTime() - starttime if (elapsedtime < duration){ rootel.scrollTop = totaldis - (totaldis * (1-Math.cos((elapsedtime/duration)*Math.PI)) / 2) scrolltimer = setTimeout(function(){jumptop()}, 10) } } jumptop() }