JSlow JS file merging according to YSlow guidelines - optimal size?

We have about 30 external Java scripts on our page. Each of them has already been approved.

To reduce HTTP requests and page load time, we consider combining them into a single file. This has been recommended by the YSlow tool.

Is it wise or is it better to combine them into, say, two files with 15 scripts each?

Is there an optimal size for combined JavaScript files?

+3
source share
2 answers

HTTP, . , , script node 1 (. http://www.yuiblog.com/blog/2010/07/12/mobile-browser-cache-limits-revisited/)

, , - . : , , , .

, HTTP-, - , . , . , [*], . - .

script , :

// This function should be attached to your onload handler
// it assumes a variable named script_url exists.  You could easily
// extend it to use an array of scripts or figure it out some other
// way (see note late)
function lazy_load() {
    setTimeout(function() {
            var s = document.createElement("script");
            s.src=script_url;
            document.body.appendChild(s);
        }, 50);
}

onload - 50 , script node . script. , javascript , - , onload 50 .

script_url script , , :

<script type="text/x-javascript-deferred" src="...">

script srcs.

, defer script, .

[*] - TCP, , . .

+9

javascript, , , , , .

HTTP- .

+2

Source: https://habr.com/ru/post/1755545/


All Articles