Minimized JS Package and External Libraries

I want to reduce the HTTP request on my website as much as possible.

Is it possible to minimize all JS in one large mini file, including external libraries such as jQuery?

+5
source share
4 answers

Yes; it is beautiful and common practice.

However, you might want to download jQuery from the Google CDN instead of including it in the kit.
This saves time for people who already have Google jQuery in cache.

+9
source

I agree with the other answers here that this is fine, but would add the following considerations:

  • SLaks, , CDN Google jquery. JQuery 60 ., , Google. CDN, . , CDN , CDN.

  • , JS . . Javascript . javascript Head , . JQuery. , , , script script, , , script , . script , script , JS .

script:

<script type="text/javascript">

    (function () {

        var script = document.createElement('script'); 
        script.type = 'text/javascript'; 
        script.async = true;
        script.src = 'http://mysite/js/mybigminifiedandmergedscript.js';
        var s = document.getElementsByTagName('script')[0]; 
        s.parentNode.insertBefore(script, s);
    })();

</script>
  • script, , , , script, , script . , script "" . .

  • .net, OSS RequestReduce, css javascript, . . Nuget RequestReduce.com.

+2

. , , , , js . , , jQuery, , - , master.

+1

- . , , .

We have a browser application that requires jquery, jquery ui, d3js, css related to them and, of course, our own code to work. In addition, clients should be able to edit the source html to generate layout options.

So, we chose one simple line "do not touch", where all the magic js and css are. We also abandoned the CDN approach, so html can be edited offline

Therefore, we have a much more reliable solution at the lowest execution price.

Ben

+1
source

All Articles